Some time ago I had this problem too. I had another Macbook with a broken main board, so I decided to wrack the connector. This showed clearly how the switch inside the connector works. It is a "normal on" switch, and it switches to off if a plug is plugged in. Then the software senses the connection to determine if this is a audio plug (metal) or a a optical connector (plastic). What happens, is that some dirt sticks on the switch, so the computer "thinks" it has a connector plugged in. Since it senses no connection, it switches to optical. The solution is clearly to clean the switch. That can be done, sometimes it might work from the outside, with the toothpick, compressed air, or whatever, but that didn't work for me. Best is to open up your mac, removing the keyboard, etc. Follow the instruction here: http://www.ifixit.com/Guide/Repair/MacBook-Core-Duo-PRAM-Battery/297/1, but not all the way! Don't remove the main board, or the cpu-cooler. Go so far that you can reach the metal strip on top of the connectors. This strip should be bend so that the connector is reachable. See first photo.The audio connector is inside a metal box. That box is for radio wave interference and for strength. So you can just wrack it open with pincers and a screw driver. Just watch out you don't drop any metal parts on the main board! When the box is removed, remove the plastic top. Now it is quite simple to clean the switch. See photo 2, the arrow is pointing to the switch. Don't be confused by the photo, you shouldn't remove the connector from the main board! On the left you see the wracked metal box. I used compressed air to clean the switch. When done (just connect the keyboard and start your mac to test), put back the plastic top, put some tape on it to keep it together and if you don't use brute force injecting a connector, you will be fine...
Hope this helps!

