My answer for most cases is 6 months of age.


For female dogs and cats spaying prior to the first heat seems to protect them from mammary cancer.  Most come into heat around 8 months so don’t wait too long.


Male cats? 6 months of age  is before they start spraying, a normal male cat behavior that is less of a problem in neutered male cats.


Male dogs do not need to be neutered.  I often wait until 2 years of age so they get the big square head look caused by testosterone.