It all depends on the iphone model and the firmware version that its on.
Not all iphones can be unlocked and if its a 3G, 3GS or iphone 4 on the latest 4.1 iOS it cannot be done at the moment.
But its not as simple as asking how do you unlock it. You need to do some research and learn how and what jailbreaking does. Different tools used, firmware and baseband versions, cydia, shsh blobs, tinyumbrella and many other things that come into play. You cannot unlock an iphone unless you jailbreak it first. (Only exception to that is the original iphone 2G)