www.shut-halacha.co.il reports a Teshuva from Rav Avigdor Nebenzahl which says:
מי שעבר ניתוח בהרדמה כללית צריך לברך הגומל, כיון שהרדמה כללית הנה
Someone who underwent surgery with a total anesthetic should say
Hagomel since a total anesthetic is a danger.
Yeshiva.org's article on Birkas Hagomel distinguishes between the views of the Shulchan Oruch and the Rema. This is a short summary:
SA: someone who is so sick that he stays in bed for 3 days says Hagomel.
Rema: someone whose life has been in danger to the extent that the Shabbos could be desecrated for him, says Hagomel. This applies even where there has been the smallest risk of danger to life.
Rav Eliezer Waldenberg (Tzitz Eliezer 12:18) requires Hagomel for any operation however minor (e.g. surgery for the eye, fracture or hemorrhoids) because there are always possibilities of complications and danger. Operations with an anesthetic also require Hagomel.
Sefardim and some Ashkenazim follow the SA; most Ashkenazim follow the Rema.