System detects digital output when headphones plugged in, audio does not work
Do you have a pair of OEM Apple headphones (from an iPhone or so)? There are some cases, that only the OEM headphones work, and 3rd party do not. If they do work, try the following:


Plug your headphones back in.
Play a bit of sound through them (e.g., a song), then stop the sound.
Make sure Preferences is quit.
Launch Preferences and open the Sound pane.
While the Sound pane is open and set to Headphones, pull out the headphone plug from the jack.
It will reset itself to "Internal Speakers" and you are good to go.