Before doing this you'll need to disable kext signing. Do it by following this guide.
Had this issue for years. If you tried to reset PRAM/SMC, reinstalled OS X, tried to fix audio port with Q-tip (don't try to if you didn't as you can damage it) and you are sure about hardware problem, there are two possible solutions.
1) Plug headphones in.
2) System preferences -> Sound -> Change Internal Speakers to an Input
If this doesn't work, try different headphones (with or without mic). I had broken ones, cut them and have been using them like this
But yesterday I discovered this method:
1) Download latest VoodooHDA Kext and Kext Utility (google it).
2) Run Kext Utility and after it finishes repairing permissions, drag VoodooHDA file right there, wait for it and restart.
After restart audio possibly will be a little low, or won't mute or won't lower, so you will need to enable the Voodoo HDA Audio fixes as needed here:
Go to /System/Library/Extensions/VoodooHDA.kext/Contents directory, change it's permissions to read/write. Do the same with Info.plist placed there.
Open Info.plist and look for "VoodooHDAEnableHalfVolumeFix" and change it's value from "false" to "true". Apply this to needed fixes and save the file. Run Kext Utility again to fix permissions again and reboot.
Hope it helps!