When it meets your standards.
Usually, it’s good to have a checklist to go through to make sure every aspect of the song is as good as it can get.
Generally pros have higher standards for themselves than amateurs, but it also depends on what you see as the destination of the song. If you just want to play something for uncritical friends and impress them with how quickly you can throw it together, it’s okay.
But it’s a world away from the writer who wants to write a hit for an established artist.
In that case, the song has to be approved by a producer, record company and the artist who are listening to (possibly) thousands of songs from the best writers they know.
They’ll put a half million to a million dollars into recording and promoting it and it better have everything it needs to entertain that artist’s audience and make them want to buy it.