In some shops yes. So if you get it from somewhere like Argos or O2 store or O2 online they are locked. I would get it from Carphone Warehouse. All phones bought there are unlocked. I got my last phone there and it was 100% unlocked. They just give you the phone as bought from the factory but with a sim card. (Sim card not in box)
From 10 November, the iPhone can be unlocked for O2 customers in the UK. Pay Monthly customers Your iPhone can be unlocked at anytime free of charge. If you unlock your handset and place a non-O2 sim into it, you will still have to honour the remainder of the minimum term on your contract. iPhone Pay & Go customers For iPhone on Pay & Go, unlocking can take place 12 months after you've bought your iPhone for a one-off £14.69 fee which will be deducted from your airtime balance. What do I need to do? Firstly, complete the unlocking form - it will take up to 14 days for the iPhone to be unlocked and we'll text you to confirm the unlock request. Then place a non-O2 sim into the iPhone and connect to iTunes via a USB cable. iTunes will confirm that the iPhone has been successfully unlocked.