Can a Mac's separate audio-in and audio-out ports be reversed in software?
Every Mac with two headphone sized jacks has one for in and one for out as the hardware is specialized for one direction. You don't need to repair the computer to remedy this if you are OK with an external DAC such as the Griffin iMic. 

The Mid 2009 MBP have identical physical connectors soldered on to the logic board, so even if the jack parts themselves are physically identical, they are wired to different parts of the sound in/out circuitry for both analog and digital and replacing that mounted part that would require a high level of soldering skill. The cheapest repair for this issue is the flat rate repair from Apple but even that is pricey when you could use tape or some other physical aid to keep the headphone in the jack as the metal latch no longer holds the pin properly.