Sotah 21a
סוטה כ״א א — ד"ה דָּבָר אַחֵר
Sotah 21a:9
A transgression extinguishes the protective merit of a mitzva performed but not the merit of Torah studied; mitzva observance protects from misfortune and the evil inclination only while actively engaged in it, whereas Torah study provides such protection both during and after engagement.
דָּבָר אַחֵר: עֲבֵירָה מְכַבָּה מִצְוָה, וְאֵין עֲבֵירָה מְכַבָּה תּוֹרָה, שֶׁנֶּאֱמַר: ״מַיִם רַבִּים לֹא יוּכְלוּ לְכַבּוֹת אֶת הָאַהֲבָה״. אָמַר רַב יוֹסֵף: מִצְוָה, בְּעִידָּנָא דְּעָסֵיק בָּהּ — מַגְּנָא וּמַצְּלָא, בְּעִידָּנָא דְּלָא עָסֵיק בָּהּ — אַגּוֹנֵי מַגְּנָא, אַצּוֹלֵי לָא מַצְּלָא. תּוֹרָה, בֵּין בְּעִידָּנָא דְּעָסֵיק בָּהּ וּבֵין בְּעִידָּנָא דְּלָא עָסֵיק בָּהּ — מַגְּנָא וּמַצְּלָא.
Alternatively, the verse associates the mitzva with a lamp and the Torah with the light of the sun in order to teach that a transgression extinguishes the merit of a mitzva one performed, but a transgression does not extinguish the merit of the Torah one studied, as it is stated: “Many waters cannot extinguish the love, neither can the floods drown it” (Song of Songs 8:7). The Torah is compared to love several times in the Song of Songs. One can conclude from the baraita that the merit of performing a mitzva is insufficient to suspend punishment. Rav Yosef said that with regard to a mitzva, at the time when one is engaged in its performance it protects one from misfortune and saves one from the evil inclination; at the time when one is not engaged in its performance, it protects one from misfortune but it does not save one from the evil inclination. With regard to Torah study, both at the time when one is engaged in it and at the time when one is not engaged in it, it protects one from misfortune and saves one from the evil inclination. Therefore, the merit of the woman’s mitzvot does protect her from misfortune and delay her punishment.