O2 lock phones purchased on Pay As You Go 'contract', in return this enables you to get the phone at a discounted price, the page here explains it in a little more detail.
In order to unlock the phone to other networks, you or who ever purchased the phone on Pay as You Go, need to complete the following O2 form here, providing the phone has been on the O2 network for 12 months, they will provide you an unlocking code, but charge you £15, however sometimes they will let you just use the credit you have on the pay as you go account.
Please let me know if you need anything clarified.
The websites which charge a few £ for unlocks, just access a database of codes whicservice providers issue.
If you have already tried contacting O2 directly and they are refusing to co-operate you could try and get the phone hacked, but there is always a risk of the operator can reapply the lock at a later date.
My guess is if you fill in the form, at worst they will just ask for another £10, since worst case you could leave it in your draw and they wouldnt make nothing from you, if you use some of the options online and ebay they tend to just be a waste of time and money based on my experience.
Please let me know how you get on with O2.