Depends when you want to leave! If you want to not go back at all, then obviously you'll need to let them know before you return - how long before depends on what your notice period is. If you want to return to work and leave after a certain period, then whether you can wait until you've returned before resigning again depends on what your notice period is.
So you want to leave in October? I'm not sure 'before or after returning to work' is the dilemma really, surely it's about how much notice to give to be helpful.
Certainly more notice than you are required to give is often helpful, as recruiting a replacement can take longer than 4 weeks. My usual caveat to employees on maternity leave wanting to tell their employer very early that they won't be returning is to wait in case they change their mind.
If you are absolutely 100% certain you will be leaving, then by all means be helpful and let your manager know sooner.