I think it's fine to ask at the end of the second date. No need to wait at all. If not then, I think it should be within a few days. If two dates have gone well I think it's good to keep the momentum going and set up the third one soon so neither person is left wondering if the other one is feeling good about how things are going.
Are you asking because you've been on two dates with a guy and now it's been awhile and he hasn't asked about a third date?
As soon as he realizes he wants to go on a third date. This should probably be after the second finishes. There is absolutely no reason to wait for any amount of time to ask someone out again. At least let them know you would like to go on another adventure with them if you know you want to pursue something a little while longer. It's ridiculous to play games once you're already in it.
Most Helpful Guys