nannybooby is wrong. Maybe he/she is getting confused with the need to have a minimum of 30 years' NI contributions in order to get the full state pension at retirement age
If the DWP know your address you will get an application pack for your pension a couple of months before you are 65. I believe it includes an exemption application form.
1-2 months is plenty of time. 1-2 weeks is probably enough
Incidentally, if you find yourself paying some contributions after you are 65 for want of the certificate being available on time, you can claim them back from NICO later. There are time limits to claim however but you should be OK if you act promptly.