When is it morally acceptable to lie? Lying is a sin. It is a violation of one of the Ten Commandments, and a disobeying of God.
However, there are many instances in the Bible where someone may lie (usually to protect someone), and God does not punish it as he would a sin, thus meaning that the act was not a sin.
When, if ever, is it morally acceptable to lie?
The 9th commandment (Ex 20:16) is about being a false witness (perjury) which implicates others to be judged guilty in a court setting.  The commandment does not prohibit all types of lying.  Being a false witness is a much more specific type of lying that is harmful to another person.  It is especially pernicious because it causes an innocent person to suffer great harm.
The obvious example you cited is lying to protect someone, for example lying to a villain in order protect someone hiding in your house.  The Bible provided at least 2 examples where the LORD in fact rewarded them for lying in order to protect others:

The midwives who protected the Hebrew babies: Ex 1:19
Rahab in protecting the two Israelite spies: Joshua 2:5

The core of Christian morality is love.  Therefore, a helpful frame to evaluate when it is morally acceptable to lie is whether in NOT lying we will be unloving.  Lying should be done as a last resort, after every other option has been considered (including not saying anything).  Or to put it in a positive and precise terms, ask yourself

In this particular circumstances where I am forced to say something about X, should I fib or even blatantly lie in order to promote X's well being while causing the least harm to everything else, including my own reputation?

For more resources:

gotquestions.org article Is it ever right to lie?
wikipedia article Thou shalt not bear false witness against thy neighbour for how various denominations (and also Judaism) interpret and expand the applications of this commandment.
The book Just Deceivers: An Exploration of the Motif of Deception in the Books of Samuel (recommended by @curiousdannii).