I'm hoping I understand your request, so here it goes:
First of all which carrier is it locked to?
Second, go to that carrier they may unlock it for free, if it's not tied to any contract (being an iPhone 3GS - it should not be on any contract by now)
I know AT&T will unlock the phone for you as long as it's not tied to an AT&T contract... Hope that helps, Good Luck!