If you're going to be volunteering often and consistently, then there is no problem in waiting until right before your application to ask for a reference. If not, then whenever you stop going, you should let them know you need one.
It's also helpful for them and saves time if you prepare a reference format in advance with all the info you would need to include and the total time you spent there (they might not remember).
In the end, as long as you get the reference before the ucas deadline, there should be no problem. In general, the more time you've got, the better, since it shows good dedication and consistency.