All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
Anesthesia does not invalidate fasting unless one is unconscious the whole day. Local anesthesia does not invalidate one's fast at all. Imam An-Nawawi said:
Our companions (scholars who follow the Shaafi‘i school of Fiqh) said, "If a person loses consciousness because of sickness, a medicine that he needs to take, or any other excuse, then the person is required to make up for the fast, but not for the prayers, that he comes to miss during his unconsciousness. The person is treated the same as the unconscious. He is not held guilty for missing the fast during his unconsciousness. In contrast, if a person loses his consciousness because of taking unlawful substances such as alcohol, then he is required to make up for the fasting and the prayer and is held sinful for missing such acts of worship."
The surgery that you went through does not invalidate the fast if it is superficial. If it is a deep surgery, then the fast is invalidated and the person is required to make up for it. Imam An-Nawawi said: "…if he stabs himself or is stabbed by someone else and the weapon penetrates his abdomen, then his fast is invalidated, and there is no difference in opinion about this. This is so whether the weapon fully or partially pierced his abdomen."
Obviously, the words of An-Nawawi apply to the surgery that you have undergone.
Allaah Knows best.