The basic method
The easiest way is to get a spare SIM card, from a different network to your current provider, and try it in your phone. A few minutes after changing the SIM cards – you should reboot your iPhone to be sure – you will see the new network name in the status bar if your phone is unlocked. If your phone is locked, you’ll get a pop-up error asking you to insert a valid SIM card.
You should do this sooner rather than later if you will be travelling. You don’t want to be stuck in a foreign country and not be able to buy phone service!
The online method
If you can’t get hold of a spare SIM card and you need to know whether you’re locked or not, there’s a website that can help. IMEI.info can access a public database of IMEI codes which tracks which phones in the world are carrier locked or not. To use this service, you’ll need to obtain your iPhone’s IMEI code – which is a code that is unique to your device.
If you have a SIM card installed, and only if, you can see the IMEI code by dialing *#06#. You can also get the IMEI code via the Settings app by navigating to General > About and scrolling down.
Alternatively, you can plug your iPhone into your Mac or PC and start iTunes. On the device Summary screen, you’ll see a line showing your phone number (the line below the phone’s data capacity). Click on the phone number, which will reveal the IMEI code. The IMEI code is also engraved on the back case near the bottom in case of some iOS devices like the iPhone 5 and the original iPhone or engraved on the SIM card tray in case of the iPhone 3G, iPhone 3GS, iPhone 4 and iPhone 4S.
Once you have the IMEI code, return toIMEI.info and input the code. You’ll see a table of basic information about your model of phone. Some details may be incorrect. For example, it reported my 16GB iPhone 5 as having 32GB.
Notice on the right of the page a set of coloured boxes. The “SIMLock and Warranty” check in green is free, however you need to register an account at this stage. After you’ve registered and logged in to your account, click on the “SIMLock and Warranty” button. It will prompt you to spread the word. Click on Check Apple phone details button to continue.
It will take a few seconds to process your request and display if your phone is locked or unlocked (next to the SIM Lock field) as you can see in the screenshot below.