If you plan to publish your book with a traditional publisher, you’ll need an agent. Most publishers only work with agents.
Even if you find a publisher who will work with you directly, you should still use an agent.
Why is that?
Because an agent will negotiate a better contract for you than you could possibly do on your own. Even if you are a lawyer or know one, an agent is still in a better position to get you the best possible deal.
Of course, if you plan to indie-publish, there is no need for an agent.