Headphone Jack Detection Sometimes my headphone jack stops working and I need to restart my computer. I can also put the computer to sleep and it will wake in the proper mode (headphone vs. speakers). Is there a way to reset whatever is causing this problem without restarting?
Double check to make sure there is no dirt in the headphone port - there is at least one sensor there that might be dirty and making it hard for the system to tell what is or is not plugged into the port. Blow it out with compressed air and/or carefully remove whatever is in it with a toothpick.

http://www.instructables.com/id/How-To-Clean-A-HeadPhone-Jack/

In many Macs, the headphone jack also has optical audio output in the same port, so if some dirt is in there, the system might think an optical cable in plugged in, so the headphone circuit will be turned off. If the system preferences says "digital", than probably this is what has happened.