Lama Ole’s answer:
That depends on the level of your practice. On the level of Theravada—the level of cause and effect, where the focus is more on oneself than on others—you should always tell the truth. Here it is very important to avoid the ten harmful actions. These are divided into three harmful actions of the body: killing, stealing, and harming others sexually; four harmful actions of speech: lying, slandering, rough or harmful speech, and meaningless speech; and three harmful actions of the mind: being greedy, hating others, and having wrong views.
On the Mahayana or Bodhisattva level, there are sometimes situations in which one can protect other beings by not telling the truth. For example, if someone comes running down the street followed by fifteen farmers armed with pitchforks who ask us where he went, then we should not tell the truth because this would bring harm to the person. On the level of the Great Way or Mahayana, there are actually only three harmful actions of the mind that we must absolutely avoid: we must not hate, not be envious, and not be confused. With our body and speech, we can do anything to benefit all beings in the best possible way.
There is a good story about this in the book The Divine Madman about the famous Tibetan yogi Drugpa Kunley. His mother was known throughout the whole village as a gossip. She was always talking about others and starting rumors. Drugpa Kunley knew that she didn’t have much longer to live and that her behavior would not bring her pleasant experiences in her next life. Because he loved his mother, he advised her again and again to learn to meditate, but that didn’t help and she held on to her habit of gossiping. One day, Drugpa Kunley ran through the village yelling at the top of his lungs, “I just slept with my mother!”—which of course wasn’t true. When this reached his mother’s ears, it was so embarrassing that she couldn’t say anything to anyone. From this point on, she used her time for meditation instead of gossiping, and when she died Drugpa Kunley was able to lead her mind into a state of liberation.
If the motivation is good, one can also lie sometimes. But it should not become a habit and should not happen out of weakness but only to protect others.