Chosen Solution
Hello! Built-in speakers in my macbook work only when I plug in the 3.5mm headphone jack (with no sound in the headphones as I plug them in). As soon as I pull it out, I have no sound from the built-in speakers as well. Its like an inversion - only when headphones are plugged, built-in speakers work. I have replased the 3.5 mm port in my mac for a new one, but it did not help. What could it be?
Surprisingly your problem is within the main logic board! I’m suspecting you had a liquid spill at some point which has damaged your audio CODIC chip which is just on the other side of the logic board. You’ll need to remove the logic board to inspect it and clean up any corrosion it has. Follow this guide MacBook Pro 15" Retina Display Mid 2012 Logic Board Replacement Look at the Cirrus labeled chip area.