I told my boss when I was about 12 or 13 weeks.
I think the rule in NSW is that you should give them 10 weeks notice of your intention to take maternity leave.