Occasionally my Mac will stop detecting the headphone jack. The only way to fix it, is to reboot, or it was until now.
In a terminal run these commands
sudo kextunload /System/Library/Extensions/AppleHDA.kext sudo kextload /System/Library/Extensions/AppleHDA.kext
This unloads the audio system and reloads it.
If it still doesn’t work, you can try killing the audio service
sudo kill -9 `ps ax|grep 'coreaudio[a-z]' |awk '{print $1}'`
After about 10-20 seconds the service should automatically start again