ALSA PulseAudio sound output when switching between headphones and laptop speaker
Solution 1:
Edit the file /usr/share/pulseaudio/alsa-mixer/paths/analog-output-speaker.conf and locate the section:
[Element Headphone]
And comment the lines
switch = off
volume = off
The end result will be
[Element Headphone]
#switch = off
#volume = off
The problem, in my case was being caused because the channel "Headphones" was being muted, and for some reason, it needs not to be muted for the notebook's speakers to work.
With my change, the headphones don't mute nor get the volume set to zero when unplugging the headphones.
To "debug" which channel is being muted in your case, you can use alsamixer, and inside alsamixer you can press "C" to select your audiocard (the default is setting the volumes for pulseaudio main channels). Plug and unplug the headphones and check what changes.