Not everyone who goes to grad school may want to be a 'postdoctoral researcher' afterwards; perhaps you are planning for a non-academia job (journalist, project manager in industry, high-school teacher, working for government at city, state, or federal level, e.g. in conservation, land management, etc.; there are also entomologist jobs in the Army, at the USDA, and other places).
If you want to end up in academia though, doing a postdoc is the normal next step after finishing your PhD. The alternative is to find a faculty position right away (some do; not too uncommon for teaching-centered colleges, i.e. ones with no grad school, and possible for research universities if you have several high-impact papers published and stellar letters).
There are essentially three ways to get funded during your postdoc period, and this also determines when & how you have to go about finding a postdoc position.
(1) Get a fellowship. This is the best alternative. Usually not-too-long lead time (find options about 6 months before you defend; apply 3 months before or so, depending on deadline). You can usually develop your very own research project, if you are lucky the fellowship will come with your own research money. This means very cheap resources for the PI, so most will welcome you even if you only let them know about your plans very briefly before you plan to come. However, it is a good idea to contact the PI you are planning to work with a few months ahead of the time you submit your fellowship application. This gives the PI a chance to give you input on your proposal, both to help you develop a good project and to hone the actual writing. Your proposal will have a much higher chance of being accepted if you do this.
Downside: almost no postdoc fellowships are available. Try:
and generally keep your eyes open at conferences, on the web, on listservs for other opportunities like that.
(2) Get a position on money the PI already has. This is probably the most common. The PI you are working with either has flexible money (they are a new faculty and have a ton of setup money; or they are famous and just got a great retention package; or some other reason), or s/he just received a grant, and now s/he is looking for a postdoc. In most cases, this means the PI will want you to do a specific project. Especially if the money comes from a grant, you absolutely have to be productive on that project; but you should be able to also give it your own stamp, contribute your own ideas to it, perhaps even develop new directions. PIs will expect this.
How to find this: contact perhaps 3-5 PIs you'd like to work with about a year before you expect to defend. 'Contact' ideally means talk to them in person, impress them with your work (e.g. by showing your poster, conference talk, or paper), and then mention explicitly when you expect to defend and that you are interested in talking about possible postdoc projects. But you can also do this by email; make sure to check in with your preferred PIs every 4 months or so (perhaps by sending your latest accepted paper). Your hope here is that the PI will keep you in mind and contact you when they have money, or consider you first when they see your application. Often however you won't be so lucky that your very preferred PI gets money, and in that case you are just responding to an advert for a postdoc somewhere. Here it will also help to have generally made yourself known for good work at conferences.
How to find postdoc ads:
Subscribe to [ECOLOG-L] and to society listservs (IUSSI, ABS)
Subscribe to Nature and Science job alerts
Check adverts posted at conferences
Ask PIs directly
There may be other places, ask other faculty you know where they would advertize for a postdoc.
(3) Write a grant with your PI. This is the hardest, mostly because it will take really long. At minimum (!), writing a successful grant will mean contacting a PI in the Fall, submitting a preproposal in January, submitting a full proposal in August, for funding by January. So this means contacting a PI to write the grant with about 1.5 years before your defense, assuming your defense is in December... But in fact getting a grant on the first try is really rare, so more likely you would go through 2-3 cycles of this before getting funding. Since it doesn't really make sense to contact PIs more than 2 years before you plan to defend (because you won't yet have much to show, and PIs won't want to commit that much if they don't even know when you'll be ready), this makes this option fairly risky. HOWEVER: contacting a potential postdoc mentor with a willingness to invest in a joint grant proposal, and a plan for how to do this, will be impressive and may convince the PI to hire you on other funding they may have. Also, the grant may actually work out, perhaps for your second postdoc. Or, if you get a faculty position, this may end up being your first grant.
If you are going to to this third option, contact potential postdoc mentors early (1-2 years before defense). Start by convincing them of your great research; then tell them explicitly you are interested in doing a postdoc with them, and willing to work on a grant. Come up with a couple of interesting grant ideas. If s/he is interested and encourages you to develop the grant, be prepared to do the bulk of the writing. Find out which NSF (or other) programs may fund it, and the exact rules/deadlines etc. The PI should mentor you on all of this, but the more you find out yourself, the more you can impress with your maturity and grant-writing-readiness.
BOTTOM LINE: Prepare for all three options. Go to conferences regularly, give great talks there. Send your published papers to potential postdoc mentors. Stay up-to-date on their work. About 1-2 years before graduation, find 3-5 potential mentors, seek them out at meetings. Tell them that you may be interested in working with them, when you expect to graduate. See what they suggest for getting funding. Pick your top favorite, suggest to her/him that you would be willing to write a grant together (do this in the Fall before you graduate or the Fall before that). Make a timeline of your graduation plans, and add any fellowship and grant deadlines. Expect that all these will be as much work as writing another paper.
And, overall: publish your work, efficiently, fast, and in good journals. No other single factor is as likely to get you a postdoc position as a long publication list (of published works, not submitted).