The simple answer to this question is - you should ask when you first meet someone and/or when you realize you do not know or have forgotten. Of course, time and place matter. Most of the time people would rather you ask their pronouns than have you use the wrong pronouns for them.
People can feel awkward or uncomfortable when they forget someone's pronouns--similar to when you forget someone's name. In both cases, there are polite ways to ask:
"Hey, Jasmine, can you remind me of your pronouns?"
"Cy, I just realized that I am not sure what pronouns you use. What are your pronouns?"