As mentioned here:
During the middle ages, it was believed that sperm produced by the left testicle produced girls. To ensure having a son, men would have it removed.
I have not heard about this before, so I doubt this is true.
I haven't found any evidence that a half castration was ever performed for this purpose. But it is an ancient belief that right testicle semen produces boys, and the left produces girls. Aristotle attributed the idea to "Anaxagoras and certain other physiologers". However, the theory that the sex of the child is determined by where the semen lands in the uterus seems to have been more prevalent, being repeated in works such as De proprietatibus rerum (c.1240) which enjoyed several republications in English (1398 & 1582) and also details castration while citing Aristotle's works.
I can't find the primary reference easily, but numerous sites attribute the idea to an 18th century French book which (in English) is titled "The Art of Boys." Wikipedia provides a formal reference:
Michel Procope-Couteaux, L'art de faire des garçons, 1770, p. 129.
I have found no indication that this advice was actually followed.
The 1750 edition of the book contains the following anecdote on p.154:
que je travail lois à remplir les vœux de la derniere qui désiroit des garçons , j'avois foin de la faire pencher du côté gauche, & soit par hasard, ou par adresse, je n'en ai eu que trois enfans, qui tous trois sont du sexe qu'elle souhaitoit.
when I work to fulfill the wishes of the youngest who wanted boys, I had to make her lean to the left side, and either by chance or by technique, I only had three children, all three of which are the sex she wanted.