The Catechism of the Catholic Church offers some insight in paragraph 2297, partially quoted here: Except when performed for strictly therapeutic medical reasons, directly intended amputations, mutilations, and sterilizations performed on innocent persons are against the moral law.
Thus treatment for cancer would allow removal, just as you can remove a limb to prevent death if the limb has gangrene that can’t be fixed.
Note: the reason for removal must be responsibly weighed against the harm. You can’t cut them off because they itch now and then.
CASTRATION. Surgical removal of the testicles. If the testes are seriously diseased, their removal is morally permissible according to the principle of the double effect.
DISCLAIMER: Catholic Answers has turned over the archive to Catholic-Questions.org and no longer owns, manages, or moderates the forums. For additional apologetics resources please visit www.catholic.com.