I had the same problem, or at least very similar:
On my girlfriend's brand new ASUS 1225C, with Ubuntu 12.04 preinstalled, the speakers worked fine at first. The second time she started it up (this time with the battery plugged in, don't know if that makes a difference), the sound only worked in headphones/external speakers.
After looking around a bit, I found this ingenious solution:
That is, I upgraded the ALSA dkms package through the link given in the bug report (https://wiki.ubuntu.com/DebuggingSoundProblems)
After I rebooted the computer, the sound works perfectly (also the switch between speakers and headphones., i.e. the speakers are silent when headphones are plugged in).
Seems easier, to me at least, than downgrading the Kernel or something drastic like that. Hope this helps someone :O)