The PulseAudio Shuffle
Ubuntu Linux uses a sound server (typically PulseAudio, or increasingly PipeWire) to manage all audio inputs and outputs. By default, this system is configured to automatically switch the active audio output device whenever a new peripheral is connected. For example, if you are listening to music on your speakers and you plug in a USB headset or connect a Bluetooth earpiece, Ubuntu will instantly mute the speakers and route the audio to the newly connected device. While this is often desired, if you are a streamer or podcaster who relies on complex, static audio routing (e.g., game audio to speakers, chat audio to headset), this automatic switching completely destroys your setup.
Disabling the Auto-Switch Module
To freeze your audio routing in place and stop Ubuntu from automatically switching audio outputs when a new device is plugged in, you must disable a specific module within the sound server configuration.
If you are running a standard PulseAudio setup, you need to edit the default configuration file. Open a terminal (Ctrl+Alt+T). Type sudo nano /etc/pulse/default.pa and press Enter (provide your password). Use the arrow keys or Page Down to scroll through this configuration file. You are looking for a specific line that reads: load-module module-switch-on-connect. This is the module responsible for the automatic behavior. To disable it, simply add a hash symbol (#) to the very beginning of the line to comment it out, making it look like this: #load-module module-switch-on-connect. Save the file (Ctrl+O, Enter) and exit nano (Ctrl+X). Finally, restart the PulseAudio server to apply the changes by typing pulseaudio -k in the terminal. Your audio outputs will now only change when you manually select them in the settings menu.