The steps are listed below, but our video takes you through the process as well:
Open iTunes and connect your iPhone up with the USB cable.
When your iPhone appears in iTunes, click it.
Click 'Restore iPhone' from the 'summary' tab.
If you're asked about un-transferred purchases, check out these instructions first.
If a software update is available for download, you'll be asked to install it. Select 'download and update' (it'll save having to do later).
This is likely to be quite large so be careful, it may leave a bit of a hole into your data quota if you're on a low volume plan.
This one's important; make sure you select 'back up' (the order of options varies between Mac and PC):
This will save your content, so it can be returned to your iPhone once it's restored.
Click 'Restore' to continue. If you're updating your software as well, it'll be labelled as 'Restore and Update'.
Wait until the restore is complete, do not disconnect your iPhone. This may take a while (over 30 minutes isn't unusual).
Once your iPhone has been restored, it'll automatically restart.
Once your iPhone is back online, disconnect and reconnect the cable for iPhone for it to be recognised by iTunes again.
Select 'restore from this backup' to reinstate the backup you did earlier.
It will take a short while for your backup to be restored to your iPhone. It'll restart again, keep your iPhone connected this time.
When prompted, choose 'update settings' to accept the carrier update (it's at this point that your iPhone will be unlocked).
Sync your iPhone with iTunes again to restore you apps, music and other iTunes content to it.