Certainly before you get a term sheet. You want to be sure your house is in order before you get the term sheet so you can close the funding as soon as possible after you get the term sheet. You don't want to be spending this important time interviewing and vetting your future legal counsel.
It is painfully obvious to investors when the startup doesn't have their legal house in order. While this is not usually fatal and they will allow time for setup and cleanup, it's a discussion you'd rather not have with an investor. For example, we set up all of our startups from the beginning on an online document repository so when legal due diligence starts, we just flip the switch for access.
Also, you will need help from your counsel to negotiate the term sheet. You want to have that person standing by so you can send them the term sheet as soon as you receive it.
Most law firms that actually work with startups will work with you before you are funded with some sort of flexible billing arrangement. We all understand that new companies can't always afford good legal counsel.