I don't have a system which I can test this out on, but I believe this section from the Arch Linux PulseAudio website should help you:
https://wiki.archlinux.org/index.php/PulseAudio/Examples#Splitting_front.2Frear
To sum up what you should do:
- Open a terminal and make a back up of
/etc/pulse/default.pa
like this: cp /etc/pulse/default.pa ~/default.pa.bak
- Open the sound settings menu and change "analog output"'s mode to "Analog Surround 4.0 Output"
- In the terminal run
pacmd list-sinks
and copy the outputted sink's name. Mine looks like "name: ", and we're interested in the bit in <>, yours should now end in "analog-surround-40".
- Open default.pa as administrator using
sudo gedit /etc/pulse/default.pa
and add the lines:
load-module module-remap-sink sink_name=speakers remix=no master=alsa_output.pci-0000_05_00.0.analog-surround-40 channels=2 master_channel_map=front-left,front-right channel_map=front-left,front-right
load-module module-remap-sink sink_name=headphones remix=no master=alsa_output.pci-0000_05_00.0.analog-surround-40 channels=2 master_channel_map=rear-left,rear-right channel_map=front-left,front-right
Replace "master=alsa_output.pci-0000_05_00.0.analog-surround-40" with the device name you found in step 3.
Now you should be able to select from "Headphones" and "Speakers" in the Sound Settings menu when you want to switch between headphones and speakers.
I would first check to see if Ubuntu is detecting both (Headphones and Speakers) in the system settings:

If you see something like one the following images, then you know both were detected:


In my case I have support for my headphones and my stereo output. If in one case I would like to disable sound for the speaker, I would first select the output I want to disable and then disable the option (Marked by the green circle). This way sound will not come out of that output connection. The same goes for input devices. Here is another image of how 12.10 looks. Notice that I have both, the Speakers connection (Analog Output) and the Headphones:

The same case applies here. You select the device you want to mute and click on the mute button.
For cases where this options do not show or sound is still coming from the speakers when you have your headphones connected then follow this steps:
Type in dash terminal
or ter
for short and press Enter

In the terminal type alsamixer
and press Enter

Inside the alsa mixer app, using your arrow keys, move left or right to any of the options that will show in your mixer window. Pressing up or down you can adjust the volume for that specific connection or pressing M you can mute the connection. What you will be doing here is looking for the one that mutes your speakers but leaves your headphones still with sound.
Now for your case, it seems your headphones are not getting detected correctly. The only option your computer shows is "Speakers" which are the internal ones. When you connect the headphones, the sound comes out of both (Speakers and Headphones) because it thinks they are the same. If you have already upgraded Ubuntu I would suggest to see what the command dmesg
outputs. Type dmesg
on a terminal and see if there is anything related to sound.
UPDATE: After looking at your dmesg and other information (Provided by Mr Jeeblez himself) and seeing that you have the Intel 5 Series/3400 Series Chipset High Definition Audio, searching I found a bug report that was made for said motherboard. You can find the bug report in
https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/580233
The solution was to do the following:
In the terminal type: sudo gedit /etc/modprobe.d/alsa-base.conf
At the end of the file paste the following:
alias snd-card-0 snd-hda-intel
options snd-hda-intel model=dell-m4-1 enable_msi=1
Save and Reboot.
NOTE: If this does not work, change in the second line the part about:
model=dell-m4-1 --> model=hp-m4.
Best Answer
I placed:
In my
/etc/modprobe.d/alsa-base.conf
I don't know which syntax is the correct one, but I left them both in for good measure.
I did NOT restore my heaphones option, however it did mute the speakers when I plugged in my headphones and that was good enough for me.