As early as possible. There are many things testers can communicate to developers that will make a system easier to test and easier to automate. Moreover, if manual testing is approached in the right way, it will be easier to automate the manual test cases. However, these benefits are unlikely to materialize if automation planning starts late in the project.