Sound problem on both Speakers and HeadPhones
Solution 1:
Try removing pulseaudio completely and installing alsa.
Check this out
Remove Pulse Audio
sudo apt-get autoremove pulseaudio
Reboot your computer or stop the pulseaudio daemon.
Install alsa-mixer
sudo apt-get install gnome-alsamixer
If you don't get any sound output run
gnome-alsamixer
For more details go to How to Remove PulseAudio & use ALSA in Ubuntu Linux?
Solution 2:
I have had this problem on my Asus K55vm laptop since 12.04. Although your solution does work, in laptops it will cause the sound to be transmitted by both the plugged headphones and the speakers. To make them work properly and only have sound come out of the headphones when plugged in or the speakers when headphones are not plugged in:
Run in terminal:
sudo gedit /usr/share/pulseaudio/alsa-mixer/paths/analog-output-headphones.conf
Find:
[Element Headphone]
Set it as:
[Element Headphone]
required-any = any
switch = on
volume = zero
override-map.1 = all
override-map.2 = all-left,all-right
Find:
[Element Desktop Speaker]
Set it to:
[Element Desktop Speaker]
switch = on
volume = zero
This works FOR ME BUT: keep in mind that when you plug in your headphones their volume will be the volume they were the last time and when you unplug them the speakers volume will be the volume it was before you plugged in the headphones.
I hope this can also help someone with the same problem as me and thank you very much bozbezbozzel! Without you I would not have made it. :)
Solution 3:
If you are running close to a vanilla install of Ubuntu 12.04LTS, try sudo apt-get update
and sudo apt-get update --fix-missing
. Now I know those are very novice answers, but it may just work. My last suggestion is to go to this answer: When I plug in headphones, my speakers mute, but nothing comes from the headphones which is loosely related to the issue you are having. If this doesn't help, try going to the audio options in system settings and make sure you have the correct output selected.