The short answer: You can file as soon as you meet the necessary requirements under the Divorce Act (meaning at least one year’s separation, or you have established one of the other criteria, namely adultery, or mental/physical cruelty). After that, you can file immediately – and in some cases, online.
If your divorce is uncontested (meaning neither you nor Ex want anything from each other in terms of child support, spousal support, or property claims) then you can file for your divorce electronically, through the Ontario courts’ website. If your divorce is contested (meaning you and your Ex may have issues to resolve, such as entitlement to support, or property law division), then you can file the traditional paper-based way.
(Note that with the COVID-19 pandemic, the divorce-granting Ontario Superior Court of Justice is not currently sitting, since it has suspended all hearings indefinitely in light of physical distancing measures. At the moment, the Court is likely not poised to process any divorce applications recently received, regardless of method. Unfortunately divorce applicants must likely wait until normal court operations resume. Although electronic filing for uncontested divorce applications was already available prior to the COVID-19 pandemic, it is unclear whether these will be given priority once court operations resume.)