There is a form you can fill in online. Here is the link to the O2 website and the form https://www.o2.co.uk/help/phones-sims-and-devices/unlocking-an-o2-mobile-to-use-on-a-different-netwo...
Alternatively you can log on to the My O2 app - Manage your account- Your device - Unlock your device.
Hope this helps
Track usage, upgrade and get support with the My O2 appDownload My O2