A lot of it depends on the person and how often you see/work with them. For example, I asked a professor in the end of the spring semester when the class I had with her was finishing, while I asked other people later in the summer when I would be able to ask them more in person.
Something to keep in mind is to ask people early enough that you still have an opportunity to search for a replacement LOR if the person you ask declines or otherwise is unable to write a LOR. I think a decent (rough) timeline for a lot of people is March/April through early June-ish.
If you don't apply this cycle, you can always ask people if they're willing to write you a LOR now (especially if you won't see them for a long time between now/when you actually apply) and then touch base with them again before the cycle when you actually apply.