The above advice is correct. Only if you're changing operators though. When I changed from a sim only deal to a contract phone with the same company (three) I never needed a PAC code. Of your changing companies, you will need your PAC code though. If you have had the same number for more than a year, then they are legally obliged to give you it for free. However, under a year you will likely get charged roughly £20. Hope this helps.
Texting PAC to 65075 should trigger the process of a PAC code by SMS. If this fails for whatever reason then you would need to log in to your online account or ring customer services, depending on who your network is with.