It's actually a myth that Mormons are required to avoid caffeine. What is proscribed are “hot drinks”, this term having been clarified to mean specifically coffee and tea, and to include cold and decaffeinated versions thereof; but not including herbal teas.
The source for this is what we call “The Word of Wisdom”, which is found in the 89th section of the Doctrine and Covenants. See
http://scriptures.lds.org/dc/89
Originally, this was given as advice, and not as a commandment. In the early days of the church, members were encouraged to obey it, but were entirely free to disregard it.
It has been narrowed and raised to the status of a commandment. In current application, the Word of Wisdom means that members are commanded to abstain from the use of:
• Strong drink (meaning alcoholic beverages)
• Hot drinks (meaning, as I said before, coffee and tea)
…and…
• Tobacco
This is “the letter of the law”, so to speak, which one must obey in order to remain a Mormon in good standing.
The spirit of the Word of Wisdom dictates that we are to take care of our bodies, and to avoid using or ingesting any product that is harmful to us. However, beyond the three things mentioned above, this is entirely a matter of personal conscience and choice. I think the following statement by Spencer W. Kimball, who was the prophet and president of the church some years ago, best clarifies the principles involved here:
“I never drink any of the cola drinks and my personal
hope would be that no one would. However, they are
not included in the Word of Wisdom in its technical
application. I quote from a letter from the secretary
to the First Presidency, ‘But the spirit of the Word of
Wisdom would be violated by the drinking or eating of
anything that contained a habit-forming drug.’ With
reference to the cola drinks, the Church has never
officially taken any attitude on this at but I personally
do not put them in the class as with the tea and coffee
because the Lord specifically mentioned them [the hot
drinks].”
(Teachings of Spencer W. Kimball, p. 202.)