I think you can leave it until just before you leave if you wish - but that was not recommended at my resettlement brief in case of errors etc. You also need to factor in the potential for delays, especially if you use the hard copy form rather than doing it electronically via JPA (don't know if that is still an option). I seem to remember that you could send off your APFS1 any time during your final year. I also heard that they start to close down elements of your JPA account in your final month (ie terminal leave period) which might add complication.
They important thing is to get your APFS1 filled in and received by "the system" before you leave. I did mine via JPA with about 4 months to run and it was pretty easy, as many aspects, including the bank details, were inserted automatically and just needed checking. However, I was not intending to move house/change banks etc and so there was little to vary. The other big advantage of the JPA route was that I rapidly received a receipt message in my workflow. It is vital that you have this confirmation, especially if you use the hard copy form, as nothing will be paid to you unless they have all the details ..............
I would echo the comment above from chinook240. I found the info from the Forces Pension Society presentation very useful in understanding who would pay the various elements of final salary, gratuity and pension, and when, after I left.
Hope this helps