I can't seem to figure out what "outside" has to do with "surgery".
Surely, one type of surgery is amputation (切断【せつだん】) which is about removing (外【はず】す) a body part, but there are many other (much more common) type of surgeries.
Japanese Language Stack Exchange is a question and answer site for students, teachers, and linguists wanting to discuss the finer points of the Japanese language. It only takes a minute to sign up.Sign up to join this community
外科【げか】 stands in contrast to 内科【ないか】. While 内科【ないか】 has the straightforwardly corresponding term "internal medicine" in English, I do not think the term "external medicine" corresponding to 外科【げか】 has as much currency in modern English-language medical materials, where instead this is rendered as "surgery". (Separately, I do note that the term "external medicine" seems to have some use in English-language Chinese medical contexts.)
That said, broadly speaking, "internal medicine" is concerned with treating the body from the inside, via medicines, behaviors, diet, etc. Meanwhile, "surgery" is concerned with treating the body from the outside, by opening things up or otherwise entering the body from the outside (such as via endoscopic techniques). This rough categorization of medical approaches is expressed in Japanese as 内科【ないか】 and 外科【げか】.