It is forbidden to cause pain to any living creature. In fact a person is required to save any living creature from pain…(Abbreviated Code of Jewish Law by Shlomo Ganzfreid, 1864).

There was an ox in the house of Rav Pappa that had a toothache. It went inside, pushed the cover off a beer barrel, drank the beer, and was healed.

https://www.talmudology.com/jeremybrownmdgmailcom/2016/7/5/bava-kamma-35a-analgesia-for-animals-g558k