Almost never. It is very rare that the death penalty is ever permissible in Catholic teaching. Only when grave danger is imminent and a society is unable to protect itself from a perpetrator can the use of the death penalty be applied as a moral justification.
What does this mean? It means that all other means of keeping a prisoner at bay have been exhausted or are unable to be made available. As an example, prisons are readily available and criminals are easily detained in them. As a result the death penalty in the United States and other places that have the ability to construct a criminal justice system to maintain law and order and detain and incarcerate criminals would not be allowed to employ the death penalty as a morally licit punishment.
There is a huge scriptural misinterpretation that often confuses people with regards to the death penalty.
The Bible states in Exodus 21:22-23:
When men fight, and one of them pushes a pregnant woman and a miscarriage results, but no other damage ensues, the one responsible shall be fined according as the woman’s husband may exact from him, the payment to be based on reckoning. But if other damage (to the woman) ensues, the penalty shall be life for life, eye for eye, tooth for tooth, hand for hand, foot for foot, burn for burn, wound for wound, bruise for bruise.
This actually suggests LIMITS, not vengeance as a moral operative. People were often killing others as retribution unjustly. The law was essentially saying that you can’t enact a punishment greater than the crime that has been committed. NO MORE THAN and eye for an eye is the measure used at this time.
We’ve come a long way since then. We do believe that criminals can be rehabilitated but we also believe in keeping others safe. And so incarceration is our measure of justice.
See the movie Dead Man Walking and hear the inspiring story of death penalty abolitionist Sr Helen Prejean and if you ever get to hear her speak, take that opportunity.