Is it permitted to cause pain or kill living creatures?
It is Biblically forbidden to actively cause pain to any living creature [for no justifiable reason, as will be explained]. [It goes without saying that one may not kill a creature for no justifiable reason.]
If the creature is a nuisance: If the creature is a nuisance to a person then it is permitted even to kill it, even though this will put the creature through pain, [and certainly one may inflict pain onto it, without killing it, in order to remove the nuisance]. Thus one may poison a dog that is a nuisance.
Midas Chassidus and Kabala:
The Arizal was careful never to kill any living creature, even if it was a mere insect and was a nuisance. This was likewise the custom of the Rebbe Rashab. Some state that one should never directly kill a creature, even if it causes pain, unless it can cause real injury, such as a snake, and one is rather to indirectly cause them to die, such as through poison. It is thus a Midas Chassidus not to directly kill a living creature with one’s hands even if it is a nuisance, and is hence permitted to do so from the letter of the law.[If however the indirect killing will cause the animal more pain, than seemingly it better to kill it directly.] The Gemara states that Rebbe Yehuda Hanaasi experienced suffering due to a certain incident that involved Tzaar Baalei Chaim, even though it was permitted according to Halacha and it was then removed after he showed mercy to animals.
May one kill insects that infest one’s food?
May one kill mice and rodents in one’s house?
Yes. Some write there is no Midas Chassidus involved in being stringent not to do so, although it is best to avoid killing it directly with one’s hands and one is to rather use a trap or poison and the like. However based on the Arizal it is a Midas Chassidus not to kill the creature.
May one kill bothersome insects such as mosquitoes and flies and the like?
Yes. Some write there is no Midas Chassidus involved in being stringent not to do so. However based on the Arizal it is a Midas Chassidus not to actively kill the creature. The Rebbe Rashab would not kill the mosquitos, but would rather brush them away with his hand.
Admur Hilchos Ovrei Derachim 4; See the article of Rav Chaim Rappaport in Koveitz Oholei Torah 993-994
Admur writes “with one’s hands”, Vetzaruch Iyun as to the meaning of these words
 This would include all living creatures, even an insect.
Other opinions: Some Poskim rule the prohibition of Tzaar Baalei Chaim only applies to animals that perform productive work. [Sheilas Yaavetz 1/110]
Admur ibid; O.C. 266/25; Rama C.M. 272/9; Baba Metzia 32b
 Some Rishonim hold that killing a creature is forbidden due to Baal Tashchis and not due to Tzaar Baalei Chaim. [Tosafus Baba Kama 115b] Other Rishonim however rule that killing creatures is forbidden due to Tzaar Baalei Chaim. [Ran Chulin 5b; Shita Mekubetzes Baba Basra 20a]From Admur ibid it is implied that killing a creature is forbidden due to Tzaar Baalei Chaim, and so rules Admur explicitly in Shemiras Haguf Vehanefesh 8.
Admur ibid; Taz Y.D. 116/6; Ramban Avoda Zara 13b
The reason: As the Torah permitted to slaughter an animal, hence teaching that when there is benefit for man we do not pay attention to the pain of the animal. [ibid]
 Literally “causing him pain”
 So is implied from Admur ibid, and Shemiras Haguf Vehanefesh 8
Admur Hilchos Shemiras Haguf Vehanefesh 8
Shaar Hamitzvos Noach Noach; Shaar Hagilgulim 38; Torah Leshma 397; See also Kav Hayashar 83 “One should not kill any creature for no reason, even if it can cause one pain, so long as it is not chasing after you”
Ramak in Or Yakar on Zohar 2/106; Igros Moshe C.M. 2/47 “Although I have not found this explicitly in sources it is proper to do so in order not to perform an act of cruelty directly and enter cruelty into one’s nature”
 See KoveitzOhalaei Torah ibid p. 32
 Baba Basra 85a
 Many different explanations have been offered in Mefarshim for why Rebbe was punished despite it being allowed. [See Maharsha ibid; Shlah Taanis; Ginas Veradim 2/15; SheilasYaavetz 1/110; Pesach Eiynayim ibid; Teshuvas Hageonim 375] Some suggest that he should have delayed the slaughter for at least some time.
Taz Y.D. 116/6
Igros Moshe C.M. 2/47
Igros Moshe ibid
Igros Moshe C.M. 2/47
Igros Moshe ibid