and you can ask why you to software switch between headphones and speakers?
Well, in the case, solve your problem in several ways:
in the forehead — buy the USB soundcard to it to pull up use, and in Ubuntu using pulseaudio/alsamixer to switch the audio output device.
the right decision — on all modern buildings have a front-panel USB and audio ports, so they connect to the motherboard and there poking headphones. if your zvukovojj firewood in Ubuntu complete plugging of the ears, the speakers themselves will varobacka. well, if you are not able then again through pulseaudio/alsamixer just cut down the channel columns/cut in the ears.
if the second is not an option I would have just soldered a small cable to the switch, and through him, hooked up and speakers and ears.