Most people here seem to answer "After the book is done." I'd have to agree. Suppose that you have a killer story, one that would make bestsellers lists the moment it came out. You query an agent, and they too are excited by it.
But then you tell them it's not done yet.
I'm sure most of the agents you ask (the honest ones anyway, dishonest ones will milk you for all you're worth) and then tell that too will not be as interested if your book isn't done. But if your book is finished, then the agents can start sending it out to publishers.
I'm in the same boat as you, I'm still revising my story, and was at one point interested in getting an agent. But people here have said that I should finish the story first, so that the agent will have something to work with. Don't rush it, or you'll end up with a bad work that even the best agent can't sell.