Better to ask too early than too late. He can either write the letter now and hang on to it until you need it or keep it in mind for later. I asked my professors for letters on the first day of class last semester just to be sure that they could do it.