As a Buddhist we should always refrain from killing especially if it is knowingly. As some of you have shared here, prevention is always better than the "cure". In this case, the word "cure" is really inappropriate!
We have to be mindful to keep our temples, homes etc clean and tidy. Keep food stored away in proper air tight containers. Make sure we do not expose food to temp rodents, pest and the like to our premises and that should eliminate the problem of having to deal with pests to begin with.
However, if we have not been doing that and we do have a pest problem, we need to address it before it actually gets worse. Worse meaning, the population of the pest may increase and we may end up killing more lives. One could say, the best thing to do is move away... well, to that I would say absolutely NO. Why? Because we created the situation so do not let someone else clean up the mess. The karma will still come back to us. We do not have to be participating in the actual killing for the karma to be created especially so in this scenario.
So if it has come to the point of having to kill in order to ensure the problem does not escalate, extensive Medicine Buddha pujas, Vajrasattva pujas need to be done to purify the karma preceding the action of killing the poor pests. However they too are not without their karmic debt. There is a reason why they have come to this conclusive situation too...
Killing pest is never the ideal situation but sometimes the lesser of two evils prevails and we have to choose one that creates the least possible suffering and negative karma. I think this applies to everything we do and hence we call it a practice.