This article about when do you need an agent describes one writer’s journey to agent and published book, in a pretty traditional trajectory through an MFA writing program and beyond. It’s a great description of that, but not exactly a how to. You most likely need an agent if you’re trying to traditionally publish a novel with a traditional publishing house, or most anything with one of the so-called Big Five. Obviously you don’t need an agent if you’re going to independently publish. Then you need an editor, a cover designer, maybe a consultant to walk you through your various options.
If you decide you want to look for an agent, the best things to do are described in the first paragraph of this article. Network, check out the acknowledgments in your favorite books, research on the internet.
My last little piece of advice here is to follow each agent’s submission guides (almost always available on their websites) to the T. Do not send them anything more than they ask for, or anything less. Rewrite your pitch until it’s razor sharp. Tell them who you are, what you want to write, and what you’re doing to get that writing out into the world. All in the briefest most direct way possible.
Research your options as you write your book. Write on!