Equal Rites by Terry Pratchett, part of the Discworld series. The introduction says:
It may, however, help to explain why Gandalf never got married and why Merlin was a man. Because this is also a story about sex, although probably not in the athletic, tumbling, count-the-legs-and-divide-by-two sense..."
Its overt focus is on the workplace and official legal inequalities: the protagonist, Esk, is a young girl with magical talent who is destined to become a wizard rather than a witch, but Unseen University is male-only. However the sub-text is also about the sexist assumptions in fantasy literature generally. At one point Esk considers the division of magic between the sexes on the Disc, which is very much the standard fantasy model:
She thought about wizards. [...] They were wise, she recalled, and usually very old, and they did powerful, complex and mysterious magics and almost all of them had beards. They were also, without exception, men.
[...] Witches were cunning, she recalled, and usually very old, or at least they tried to look old, and they did slightly suspicious, homely and organic magics and some of them had beards. They were also, without exception, women.
There was some fundamental problem in all that which she couldn't quite resolve.
Later on the book also touches on birth control and sex when Esk meets Hilta Goatfounder, a town witch:
"The council have tried to run me out once or twice, you know, but they all have wives and somehow it never quite happens. They say I'm not the right sort, but I say there'd be many a family in this town a good deal bigger and poorer if it wasn't for Madame Goatfounder's Pennyroyal Preventives. I know who comes into my shop, I do. I remember who buys buckeroo drops and ShoNuff Ointment, I do."