The only time that Torah says it is ok to steal is to steal food only if you cannot obtain money through charity.
Where does the Torah say this?
I have heard this said, and can find examples of this principle:
http://www.jlaw.com/Articles/ch_stealsavelife.html
Stealing To Save Someone's Life
by Charles J. Harary, Esq.
Mr. Harary is associated with the law firm of Davis, Polk & Wardwell
To what extent can a person go to save a life? Can he steal? Can he destroy the property of another? If so, what is he liable for? Must he compensate the owner of the property? Consider the following famous scenarios:
1. "A" is stranded in a remote area by an unexpected blizzard. He breaks into an unoccupied cabin and waits for three days until the storm abates and he may safely leave. During that time, the backpacker consumes the food stocks in the cabin and breaks up his unknown benefactor's furniture, burning it in the fireplace to keep warm.1
2. "H," a diabetic, loses his insulin in an automobile accident. Before "H" lapses into a coma, he rushes to the house of "C," another diabetic. "C" is not at home, but somehow "H" manages to get into her house. After first assuring himself that he has left "C" enough insulin for her own daily dosage, "H" takes the insulin he needs to survive.2
I.THE APPROACH OF JEWISH LAW
A. Saving one’s own life
God, through the words of the Torah, places utmost importance on the value of life. In Vayikra, the verse states: "ushmartem et chukotay ve’et mishpatai asher ya’ase otam ha’adam, vechai bahem, ani hashem."3 You shall observe my decrees and my laws that each man shall carry out and by which he shall live, I am God. This verse teaches us that the commandments were not meant to take precedence over human life. If the observance or the performance of a Torah law would create a risk to a human life, then preservation of that life should take precedence over the observance of that Torah law.
The Gemara in Sanhedrin4 rules on the basis of this verse that if someone is offered the ultimatum to violate one of the prohibitions in the Torah or be killed, that person has the duty to violate that law and save his life. This rule applies to all the prohibitions in the Torah with three exceptions. The three exceptions are the prohibitions of idol worship, illicit sexual relations and murder. Although the Torah specifically says "vechai bahem," if a person would be given the ultimatum to violate one of these three transgressions or be killed, he must refuse to violate the prohibition and sacrifice his own life.
The same Gemara in Sanhedrin,5 describes a case where a person being pursued destroys the property of another in effort to save his own life. Rava rules that if the property belongs to the pursuer, then the pursued is exempt from compensating the damage. However, if the person being pursued destroys the property belonging to a third party, he is liable for the damage. We see from this Gemara that it is permissible to destroy another’s property to save your own life, provided that you compensate the owner of the property.
It seems from the pasuk "vechai bahem" and from the Gemara in Sanhedrin that only the three major transgressions take precedence over saving one’s life; all other laws may be violated for pikuach nefesh. Since stealing or destroying property is not one of the three exceptions to the rule of "vechai bahem," it would seem obvious that one should steal and destroy property rather than die. The Raavad in fact rules this way.6
Despite the seeming clarity, there are sources that indicate that one may not steal even if it is for pikuach nefesh. The Binyon Tzion, Rav Yaakov Ettlinger, brings two sources that show authorities of the opinion that it is forbidden for a person to steal even if his life depends on it.7
The first source is a Gemara in Bava Kamma8 that relates a story from Sefer Shmuel about King David.9 King David was fighting the Philistines when he became very thirsty. He said "if only someone could give me water to drink from the well of Bethlehem which is in the city of the gate." Upon hearing this, three of David’s men broke through the gate and retrieved water. Before drinking, David sent a question to the Sanhedrin, asking permission to drink the water, to which they responded in the negative. The Gemara understands the passage to be speaking of David’s wish for halachic guidance. The "mayim" being referred to was not physical water but the waters of torah. According to R’ Huna, the question David was asking was whether he was permitted to destroy the property of another for pikuach nefesh. David and his army were in the middle of a barley field where the Philistines were hiding. He wanted to torch the field so that the Philistines would retreat and thereby avoid an ambush on his army. The problem was that the barley field belonged to another Jew. David inquired if he could save himself and his army by sacrificing the property of another. The Gemara states that the Sanhedrin sent him back a ruling that it was forbidden to destroy the property of another to save his life, however since he is king, he has the power to do what he wants with the property of his people.10
From this Gemara a conflict arises between Rashi and Tosafos. Tosafos maintains that David was not asking the Sanhedrin if property destruction was permitted to save a life, because that was obviously permitted. David was aware of the rule that when there is a possible danger to life, one may transgress any sin in order to escape the danger, with the exceptions of idolatry, forbidden relations and murder.11 Thus, one is clearly allowed to destroy someone else’s property in order to remove a threat to life. David’s question was whether he was liable to compensate the owner if he burnt the field. The Sanhedrin responded that it was forbidden to burn the property without compensating the owner. Tosafos further explains that the reason this rule is stated in the gemara in terms of a prohibition (It is prohibited for a person to save himself…) is to imply a caveat where there is another way to save oneself that does not entail the destruction of another’s property, one is indeed prohibited from destroying that property.12
The Rosh13 agrees with Tosafos and states that the Gemara never contemplated whether it was forbidden to save the life of the Jewish army at the expense of someone else’s crops. Such a ruling was obvious since nothing stands in the way of pikuach nefesh except the three cardinal sins. David was inquiring about compensation to which the Sanhedrin responded was obligatory.
The Binyon Tzion states that Rashi disagrees with Tosafos’ understanding of the Gemara and maintains that the Gemara should be interpreted literally.14 King David asked whether he could burn the field to save his soldiers, which the Sanhedrin prohibited. According to Rashi, a person is not allowed to steal or damage another person’s property even under threat of death and even if one will repay the loss. Therefore it is Rashi’s opinion that one may not steal even if it is for pikuach nefesh.
The second source that the Binyon Tzion discusses is a Gemara in Kesubos,15 that describes a scenario where a witness is given the ultimate to sign a false note, which will award money to an undeserving party, or be killed. Rav Chisda says that Rav Meir rules that in such a case one should allow himself to be killed rather than sign the note since signing the false note would be stealing. Rava disagrees with the view of Rav Chisda and rules that the witness may sign the note since nothing stands in the way of mortal danger other than the three cardinal sins, which stealing is not a part of. The Rambam states that Rav Chisda’s interpretation of Rav Meir is correct, and brings a Braisa Kitzonis (excluded beraisa) to show that R’Meir adds theft to the list of the cardinal sins holding that stealing is a form of killing. Additionally, the Shitta Mekubetzes in Kesubos16 quotes from the Rambam that the question of whether or not stealing should be the fourth of the cardinal sins may be a matter of dispute among the Tanaim.
In addition, there are sources that seem to imply that stealing is forbidden even for pikuach nefesh. Meseches Yoma17 records a story where a Tanna stole a loaf of bread from a farmer in order to save his life, and was rebuked for doing so. In Bava Kamma18 there is a case where the Rabbis objected to a person keeping in his possession an animal that grazed other people’s property, thereby stealing from others even though the animal was needed to save the owner’s life. The Yershalmi in Avoda Zara19 implies that stealing is equal to the three cardinal sins of Judaism. Forcing someone to steal is like forcing him to kill. Since one cannot kill to save a life, one cannot steal either. The Beraisa in Meseches Semachos20 compares one who steals to one who murders and worships idols; the Vilna Goan21 compares a thief to an adulterer and a violator of Shabbos. From these sources, we can see that although theft is not formally on the list of cardinal sins, there are authorities that believe that theft is similar enough to murder, adultery and idolatry that it is forbidden to transgress even at the expense for the sake of pikuach nefesh.
Despite these sources, the halacha follows the views that one can steal for pikuach nefesh, but only on the condition that the property be returned or the owner compensated for the property’s value.22 The Shulchan Aruch23 states that, except for idolatry, illicit relations and murder, a person is permitted to transgress all the sins in the Torah rather than be killed. Therefore, if a person’s life is in danger and he must steal to save himself, he can do so. However, he must have the specific intention to pay back the owner. The Rambam24 rules that if a person commands a Jew to transgress one of the commandments or be killed, he should transgress rather than be killed. He learns this rule from the pasuk "vechai bahem." Moreover, if a person is in this situation and chooses to die, he is guilty on his life.25 The Rambam applies the law to all commandments except idolatry, illicit relations and murder.26
...