sudo gedit /etc/pulse/default.pa
Find the lines that state:
.ifexists module-switch-on-connect.so
load-module module-switch-on-connect
.endif
Comment out those lines:
# .ifexists module-switch-on-connect.so
# load-module module-switch-on-connect
# .endif
Find the line which states:
load-module module-switch-on-port-available
And comment it:
# load-module module-switch-on-port-available
Alternatively, you can forego all of the above and try changing:
load-module module-stream-restore
to...
load-module module-stream-restore restore_device=false
Your last-used audio sink will stay set, but you'll have to manually choose which audio sink you use, rather than it auto-switching when you, for instance, connect a USB headset.
The reason it does this is because different audio sinks become available at different times as the machine boots... it should ignore all that as the machine is booting, then load the last-used or most-recently plugged-in sink after the machine is booted.
I'm betting your speakers don't come available first during boot, so PulseAudio reverts to your headphones as fallback.
I'm looking at a way to disable auto-switching during boot. If I get it working, I'll update.
cat ~/.config/pulse/*default-sink
- to show default card name
pactl list sinks | grep 'Name'
- to show names of all active sinks
pactl set-default-sink <Name>
- to change the default sink, using the list of all active sinks as a guide
You might also try pasystray:
sudo apt install pasystray
pasystray allows setting the default PulseAudio source/sink and moving streams on the fly between sources/sinks without restarting the client applications.
Or the more recent Sound Switcher Indicator, which plays better with Gnome:
sudo add-apt-repository ppa:yktooo/ppa
sudo apt-get update
sudo apt-get install indicator-sound-switcher