Yes, you'll need a new contract whilst maintaining your current one.
When you get your new contract, call O2 to migrate your number and they will generate the final bill on your old contract, including the final months payments.
You will have to pay both contracts for one month up to the point you migrate your number.
So assuming I want to stay with O2 but from a third party from uSwitch I would need to purchase a new contract and have the phone and sim delivered then phone O2 and get them to move my old number to the new contract and sort out the final bill?
Yes, exactly that @DanielCrocker
You'd get a PAC to keep your number Guide: How to get your PAC [June 2021 Update]
which would end your O2 contract when your number ports to the new network.
You would still get your final bill from O2 as above though.
Track usage, upgrade and get support with the My O2 appDownload My O2