This article from Ohr Samayach discusses some of these issues:
Putting animals "to sleep."
Richard from Mt. Vernon, NY, wrote:
As a "follow-up" to your answer about Euthanasia, is it Halachically permitted to put animals "to sleep"?
Dear Richard,
The prohibition against causing pain to animals is a serious one, and is treated as such by Jewish Law, which not only forbids man from causing pain to animals, but also bids him to help relieve the pain of animals.
I spoke to Dr. Kaufman, a Jerusalem veterinarian, to find out what putting animals to sleep involves, and under what circumstances the procedure is done. She told me that, in general, she would do this only for animals that had been in an accident and the ensuing treatment would be too costly, or for pets dying and in pain.
Though, when Dr. Kaufman was working at the Tufts University Animal Clinic, a woman wanted her dog "put down" for an unusual reason: She had just redecorated her house, and her "lovey, lovey, koochie koo" no longer matched the decor! Even though Dr. Kaufman suggested giving the dog up for adoption, the lady refused, stating that if she couldn't have her "lovey, lovey" then no one could!"
The general method for putting an animal to sleep is to give it Phenobarbital, an anesthetic. Once the animal is unconscious, it is given an overdose. The method for putting many animals to sleep at one time is to gas them with Carbon Dioxide, an anesthetic that eventually stops their breathing. In short, every effort is made to make the process painless.
I asked Rabbi Chaim Pinchas Scheinberg, shlita, about the ruling in this case, and he told me that it would be Halachically permissible to put an animal to sleep since it is a painless procedure. However, there is a Kabbalistic tradition, he notes, that forbids the ending of any life.
Rabbi Aryeh Levin tells a story about a walk he once took with Rabbi Kook. While they were walking, Reb Aryeh "absent-mindedly" pulled a leaf from a tree. Rabbi Kook stopped and asked him why he did that. "Why I did what?" responded Reb Aryeh. Reb Aryeh relates that Rav Kook illustrated to him how one should be very careful about life, even the life of a leaf.
Sources:
Shemot, 23:5.
Talmud - Tractate Shabbat 128b.
Shulchan Aruch - Choshen Mishpat, 272:9.