daf bit: Sanhedrin 73-74
The mishna teaches: the following must be saved from sinning even at the cost of their lives: one who pursues his neighbor to slay him (the rodef), or pursues a male for illicit relations, or pursues a maiden to dishonor her. But one who pursues an animal to violate it, or who would desecrate Shabbat, or who would commit idolatry, must not be saved at the cost of his life. There is disagreement in the g'mara about the idolater and the Shabbat-desecrater, and this leads to the well-known teaching of when a person must sacrifice himself rather than sin. In all torah laws save three, if one is told "transgress or be killed", he transgresses; the three exceptions are murder, illicit relations including adultery, and idolatry. This is then clarified: one transgresses to save his life only if it happens in private, but if told to publicly violate even a minor mitzvah or die, he must accept martyrdom. (73a mishna, 74a g'mara)