I'll put the disclaimer right at the top for such a sensitive issue: See both your local orthodox Rav and local orthodox doctor if this Chas v'shalom becomes relevant to you.
There are various restrictions in place from Rosh Chodesh Av for Ashkenazim and just during the week of Tisha B'Av for Sefardim. These are discussed in OC 551.
The relevant portion is the final halacha in the siman, halacha 18:
צריך ליזהר מי״ז תמוז עד ט׳ באב שלא לילך יחידי מד׳ שעות עד ט׳ שעות משום שבהם קטב מרירי שולט ולא יכו התלמידים בימים ההם
One must be careful from 17 Tammuz to 9 Av not to walk alone from the fourth to ninth hours of the day, when Ketev Meriri rules, and one should not hit his students during these days.
(For the curious, Ketev Meriri is a demon discussed in Pesachim 111b, Midrash Tehillim 91, Eichah Rabbah 1:29, Bamidbar Rabbah 12:3, Yalkut Tehillim 842, and Tanchuma Nasso 23. The discussion about the existence of demons may be taken elsewhere.)
What's wrong with these activities that they are forbidden during this time of year? This is sourced in the above Eichah Rabbah and Tanchuma Nasso, which describe the havoc wreaked by Ketev during this time period. Accordingly, one should avoid doing things that are dangerous, lest one tempt Ketev to finish him off. The Midrash cites the example of a man being chased by another wielding a wooden stick. The latter was stopped by R' Avahu, who, seeing Ketev chasing him with an iron stick foresaw that were the man to beat his fellow with the wooden stick, even though he didn't intend to kill him, Ketev would continue the beating and kill him. For similar reasons, a teacher may not hit a student (which, before the government would arrest you for child abuse, was a perfectly normal form of rebuke), for fear of inciting the demon on the child.
It's for this reason that one may not do anything dangerous during these days (R' Moshe in Shmaytsa d'Moshe, p. 428; R' Wozner in Kovetz MiBeis Levi, Bein HaMetzarim p. 11 sec. 12; et. al.).
The Hisorerus Teshuvah (ironically, in Simon 348 - שמח) holds that the prohibition of one walking during high noon applies even in a city, something absolutely normal. The Chazon Ish (Dinim v'hanhagos 20:8) and Aruch HaShulchan (OC 551:39) argue, saying that it refers to things most people would consider dangerous, like walking alone outside of a city. R' Kanievsky (Nechamas Yisrael 8:161) was even concerned for one going to do a mitzvah, something even the Hisorerus Teshuvah said was okay. (All of the sources in the last two paragraphs may be found in the Dirshu Mishnah Berurah to 551:18.) Another question quotes R' Shlomo Zalman that one may do dangerous things for the sake of a mitzvah during this time.
What about a surgery? It seems obvious that a surgery which absolutely cannot be done after Tisha B'Av can and must be done before. But what about a necessary surgery which could be pushed off? Seemingly, this would be subject to the debate between the Hisorerus Teshuvah and the Chazon Ish/Aruch HaShulchan: Is the prohibition against doing things dangerous limited to things typically considered dangerous, or even more regular activities that could potentially be dangerous? The same way that the Hisorerus Teshuvah prohibits walking alone even in a city, would he prohibit a surgery?
What about working backwards from Bris Milah? The Rema not once (OC 551:9) but twice (:10) discusses a se'udas mitzvah for a Bris during this time period, and the Kitzur Shulchan Aruch (122:15) explicitly addresses the case and permits it, discussing what the ba'alei simchah may wear in light of the prohibition against laundry during this time. May one prove from here that a regular surgery is permissible? In general, if it's dangerous to the baby, we push off the Bris Milah. From the fact that it is done anyway, may one prove that regular surgeries are not considered dangerous enough to be prohibited? Or perhaps there's no proof, as a Bris Milah is a mitzvah, and several commentaries (Taz, Mishnah Berurah) to the aforementioned OC 551:18 make clear that going for a mitzvah is permitted. Then again, there is the aforementioned R' Kanievsky who was concerned for one going to do a mitzvah...