Are you allowed to kill flies and other pests (mice, mosquitoes, etc.) or would that go under the prohibition of Tzar Balay Chaim?
Reb Moshe in Iggras Moshe (חושן משפט חלק ב' סימן מ''ז) says if it is disgusting and or the creature ruins food,or mosquitoes who bother the person the answer is YES. Reb Moshe in an Illustration of his Tzidkus (righteousness) adds of course you should try not do it by hand instead with fly traps and the like because killing by hand desensitizes you and ruins your character. He brings the Ohr Hachaim Hakodsh (דברים י"ג י"ח) who says that even the person who kills for the Beis Din and a Shochet needs a special protection against this provided by the Torah because he is directly involved in doing a Mitzvah but here where he is just ridding himself of a bother he should try his utmost not to do it by hand.
Tzar Balay Chaim means causing pain. Killing is explicitly excluded (as long as you do it properly) since once dead the animal no longer feels pain.