Check this article:
To unlock your iPhone, check with your carrier to ensure that they offer unlocking and that you meet the requirements to obtain an unlock. If both those requirements are met, ask your carrier to unlock your iPhone, then follow these instructions:
- Ensure that you've waited the recommended wait period provided by your carrier.
- Back up your iPhone.
- Erase the contents of your iPhone.
- Swap the old SIM card with the one for the new carrier.
- Complete the setup assistant and restore your backup.
Follow the steps below if you experience issues or receive the following error message displayed in iTunes or on your device:"The SIM card inserted in this iPhone does not appear to be supported. Only compatible SIM cards from a supported carrier may be used to activate iPhone. Please insert the SIM card that came with your iPhone or visit a supported carrier store."