In Ubuntu 12.04 laptop when you plugged in headphones, sounds may come out from both headphones and speakers. Here is a solution:

  • Open terminal from the dash home or press Ctrl+Alt+T, add the ppa:
    sudo apt-add-repository ppa:ubuntu-audio-dev/alsa-daily
  • update the source:
    sudo apt-get update
  • Install alsa-hda-dkms package:
    sudo apt-get install alsa-hda-dkms

Reboot and see effect!