You can apply at any time when you have a filing or reporting requirement.  It’s best to apply as soon as possible. This will help you avoid any delays in processing your tax return and ensure that you don’t have to pay penalties or interest if the IRS has not yet assigned an ITIN number.
It’s worth noting that even if you are not currently required to file taxes, it’s still a good idea to apply for an ITIN to have it for future use since it can also be helpful for other purposes such as opening a bank account.