Normally at least two months before the planned start of work to the party wall. The notice is only valid for a year, so it should not be served too early.
Follow the link for more information on Party Wall Notices and when to issue them.