The unlocking process for Apple iPhones depends on which model you have.
If you have the Apple iPhone 5 or newer, your phone may already be unlocked (if you are an Optus or Telstra customer) although you may need to do a software update on your phone for the unlocking to take effect.
The unlocking process is considerably more complex if you have an older model iPhone and it can take up to 72 hours to unlock an Apple iPhone.
To unlock an iPhone you will need to contact the phone network that you purchased your iPhone through. They will ask for your phone’s IMEI number, which you can find out by going into your phone’s settings (Settings > General > About) and within a few days you will receive a text message saying that your phone has been unlocked. Please note that this text message doesn't mean that the unlocking process is complete. You will still need to connect to the latest version of iTunes (with your new SIM card in the phone) to restore your phone. If you do not restore in iTunes, your unlocking process will not be complete.
Once your iPhone has been unlocked, you will see a screen like this in iTunes:
Double check that your phone has been unlocked even if Optus or Telstra tell you that it is unlocked.
The best way to test this is to insert a SIM card from a completely different network to see if your phone will work on a different SIM card. For example you can test that a Telstra phone is unlocked by inserting an Optus or Vodafone SIM card. It must be a SIM from a completely different network and using an Aldi Mobile or Lycamobile SIM is no way to test that a Telstra phone is unlocked (Aldi and Lycamobile use the Telstra network), likewise don't use an amaysim or Virgin Mobile SIM to test that your Optus phone is unlocked (amaysim and Virgin use the Optus network) and don't use a Lebara SIM to test that a Vodafone phone is unlocked. You must test with a SIM card from a completely different network.
As long as your international SIM card is active you will be able to your this SIM to test that your phone is unlocked, however if you do this it is important to turn off data roaming to avoid any roaming charges. O2 UK SIM and T-Mobile USA SIM cards (on the Pay By The Day plan) are sold pre-activated and can be used straight away to test that your phone has been unlocked. T-Mobile USA SIM cards (on a monthly prepaid plan) can be used to test your phone once your activation date has passed. However 2degrees New Zealand and Lebara France SIM cards cannot be used as these are not active until you arrive at your destination.
Unfortunately both Optus and Telstra staff have been known to regularly tell people that their phones are unlocked when they are in fact still locked into the Optus or Telstra network. This is often the case with iPhones as these may show as being unlocked when checked by Apple, Optus or Telstra, however these are not unlocked unless you have completed the unlocking process by restoring your phone in iTunes on your computer.
Most iPhones purchased from Apple Stores are sold unlocked and are ready to use with any SIM card, however it is still best to check by inserting a SIM from a different network as some Apple Stores overseas still sell locked iPhones. Also if you have previously unlocked your iPhone, but then had your phone replaced by Apple under warranty your new phone may be locked into your old network and may require unlocking.
This is very important. You won’t be able to use the T-Mobile USA SIM card (or any other SIM card) if your phone is locked and not compatible with the US network. It should only take 5–10 minutes or so to check these things, and doing this will avoid any dissapointment when you arrive in the United States.
Step 1: Start the unlocking process with your network
Unlocking an iPhone from Telstra
You can start the unlocking process for an iPhone purchased from Telstra online at https://unlock.telstra.com/.
Unlocking an iPhone from Optus
To unlock an iPhone on the Optus network you need to call 1300 075 395. This is a 24-hour service for processing iPhone unlocking requests. You will need your phone's IMEI number, the Optus phone number that you normally use on your iPhone as well as your date of birth.
Unlocking an iPhone from Virgin Mobile
Unlocking an iPhone from Vodafone
You can start the unlocking process for an iPhone purchased from Vodafone online at https://unlock.vodafone.com.au/
You can read more about unlocking iPhones from Vodafone here.
Step 2: Complete the unlocking process in iTunes
Once your phone has been unlocked at your network's end, you will need to restore your phone in iTunes to complete the unlocking process.
This page on the Vodafone website has very good step-by-step instructions on completing the unlock process in iTunes: http://support.vodafone.com.au/articles/FAQ/Unlocking-your-Apple-iPhone (even though this information is on the Vodafone website, the process is the same for customers from other networks including Optus and Telstra customers).
You may be able to complete the unlocking process over a Wi-Fi data connection (without the need to connect to a computer) if you have the latest version of iOS installed on your phone and usually back up your phone using iCloud. If this is the case you will need to connect to a Wi-Fi network and log into your iTunes account when prompted.