I know some vets who say 6 months and some who say older like 18 months for a big dog like a Lab or Great dane or a sport dog eg Border collie chosen for agility (or herding).
And the AWL vets will do it as young as 8 Weeks. And they get very good at working with tiny puppies.
There are pros and cons to early, medium and late desexing.
If you want to keep the dog puppy like to some extent - then early before first season is best but there are studies that show you can end up with a dog whose frame is taller and narrower than they would otherwise have been and some think that leads to extra joint problems. Sometimes an early desex can lead to incontinence (in a bitch) when older - but so can a badly done desex or difficulty delivering puppies.
So you need to decide what kind of dog you want, and what the breeder of that dog or their vet recommends, and what you want to do with your dog, and how much mess in terms of a menstruating bitch you want to deal with.
If you get a dog from rescue - chances are you won't get a choice. Rescue people are in over their heads with unwanted puppies and do their best to limit the opportunities to make more.
Here are some links to help confuse you.
Chapter 2 - Dispelling the Myths about Long-term Side-effects of Early Age Desexing - Department of Environment and Primary Industries
Early desex and the canine athlete pdf
Personally - if I get a rescue dog - I will go with the flow. If I choose to get a dog from a breeder - I will negotiate permission to desex at about 18 months old as I think this gets the best balance between bone and muscle strength and avoiding various diseases associated with the dog's sex organs. I'd probably have to manage three heat (messy) cycles.