As soon as possible. As soon as you are contemplating a transaction, you should speak to a lawyer. This is because the lawyer may identify risks that you have not thought of that may change the nature or structure of the transaction. It also allows you to identify nasty surprises in the documents (such as the example provided in the previous FAQ).
For example, we had a client that entered into a loan agreement that only permitted them to lodge a caveat as security over land. In the particular circumstances, a mortgage would have been the preferred and more appropriate security. However, the client had already signed the loan agreement. The other party naturally refused to change it.