Read a great tutorial on how to unlock your 3G iphone for FREE at iClarified here
I have tested this personally on my own O2 UK 3G iPhone and it works great!
Note: The latest software version for the 3G iPhone is 2.2.1. It is not currently supported by YellowSn0w. But rumors have it that a new version of yellowSn0w is about to be released (version 0.98) which will work with 2.2.1. Keep an eye on the dev team blog for updates.
If you are already running version 2.2.1 and want to unlock it, then for now you will have to wait for YellowSn0w 0.98 to be released. Some "Unlock SIM's" do claim to work with 2.2.1 but i have heard mixed reports on their reliability (read tutorial below for more information on unlock SIM's).
UPDATE: There is no news from the iPhone Dev team yet about unlocking version 2.2.1. So unlock SIM's are currently the only solution for this version. Please read my tutorial below for more details. Hopefully they will crack it soon....
If you have any questions about iPhone unlocking please post them in my new support forum here.
I have left my older tutorial below as it may become useful again when Apple release newer software versions that might require the use of "unlock SIM's" again.

Basic Facts about unlocking the 2G & 3G iphone
This tutorial is aimed specifically at the 3G version of the iPhone. if you have a standard 2G iphone it can be easily unlocked using the USB cable provided with your iphone. Have a read of the guide in the link below:iclarified.com unlock 2G iphone Guide (does not work for 3G iphone)
If you know of a better guide to unlock the 2G iphone, contact me. I will post a link to it here.
iPhone Unlock SIM's

Sadly the unlock solution for the 3G iphone is not so neat. As of November 2008 there is no software based solution to unlock your 3G iphone. But don't worry, some clever people have discovered an alternative method. It is through the use of what is commonly referred to as "Unlock SIM's" or "piggyback SIM's". Have a look at the picture to the right to see what they look like (there are different variations but they all look pretty much the same).
Now these unlock SIM's are very thin and you simply need to place them on top of the the actual SIM card you would like to use in your iphone. Finally place them into you SIM holder and then into the iPhone. Its probably easier to see this in action. I found this great American video on You Tube that shows you exactly how it works.