From https://www.avma.org/resources-tools/avma-policies/disbudding-and-dehorning-sheep-and-goats
Disbudding of goats reduces the risk of injury to the goat, other animals, and people. Goats are best disbudded between 5 and 7 days of age. By 14 days of age, the developing horn tissue will have attached to the skull and is more difficult to remove. Therefore, disbudding should occur prior to 14 days of age to avoid having to dehorn. Dehorning of goats over 14 days of age must be performed by a licensed veterinarian and should only be performed where the health and welfare of the animals or the safety of humans are impacted by the presence of horns.
Disbudding and dehorning of sheep are not routine procedures and must only be performed by a licensed veterinarian when medically necessary.
Disbudding and dehorning cause pain and distress. Therefore the AVMA recommends the use of procedures and practices that reduce or eliminate these effects, including the use of approved or AMDUCA-permissible clinically effective medications.
The AVMA encourages research leading to new or improved techniques and approved pharmaceuticals that reduce or eliminate pain and distress associated with disbudding and dehorning.