If you look in your headphones jack, is there a red light on?
If yes, then you have Digital Out on, and this messes with the speaker configuration.
There is a thread here, which has some possible fixes.
There is switch inside the jack that is stuck. Plug the speaker jack in and out several times while watching the Sound-output system preference panel. The internal speaker option will come on if the switch is unstuck.
Taking a toothpick and fiddling around inside the jack has solved the problem for some, you should try this. (Don't break the toothpick inside :) )
The problem is actually caused by a little switch inside the jack that gets stuck. When you stick in an audio cable, it pushes the switch down. If it's an analog cable, the end is made of metal. If it's optical, the end is made of plastic. If the switch is pressed down, the computer checks to see if the plug inside is metal or plastic based on conductivity. When it gets stuck and nothing is in there, it thinks an optical cable is plugged in since the switch is down but nothing conductive is in there. That's why it works with headphones or external analog speakers.