Q: Mid-2009 15" MBP Line-out / Headphone-out jack not working properly - how to resume behaviour without replacing Logic Bus?
You will be amazed what can collect in the headset socket over the years, hindering its proper functioning. Giving them an occasional good cleaning will keep them running.

First, use a tooth pick and try to remove anything that could be stuck in there.

Next use a q-tip soaked with alcohol and swipe in there to clean the contacts.