It depends on the policy but usually you need to give 8 weeks notice in writing but the sooner the better so they can arrange cover. In terms of leaving, do you have any annual leave you can add on to the end of the maternity leave? Would buy you some more time, I would wait it out personally before leaving
Tbh if you weren’t wanting to go back and you’re not getting an enhanced allowance I’d stay with them until near the end of your mat leave so you’re still getting SMP and then hand your notice in x