Shevuos chapter 3, mishnah 6. This mishnah deals with an oath concerning a mitzvah - both an oath to fulfill a mitzvah and an oath not to fulfill it.
One who swore to nullify a mitzvah and did not nullify it:
The mishnah rules: "Nishba levatel es hamitzvah velo bitel - patur" - one who swore not to fulfill a mitzvah and did not nullify it is exempt. A person who swore that he would not perform a mitzvah - for example, he swore not to put on tefillin - and in the end did put on tefillin, is exempt from liability for violating the oath, because the oath never took effect: after all, he already stands sworn from Mount Sinai to put on tefillin. However, he is guilty of taking a vain oath, since this oath was meaningless from the outset and had no power to take hold and become binding.
One who swore to fulfill and did not fulfill:
"Lekayem velo kiyem - patur" - one who swore to fulfill a mitzvah that he is obligated in anyway, and did not fulfill it, is likewise exempt from the liability for violating an oath. Obviously he has transgressed by failing to perform the mitzvah itself, since he did not fulfill it, but he is not considered someone who violated an oath.
Moreover, in this case the oath is not considered a vain oath, because a person is permitted to take an oath in order to rouse and spur himself on to fulfill the mitzvos of the Torah - and that is precisely what he did. Even though in practice he did not fulfill the mitzvah, at the moment he swore his oath had a purpose and was not for nothing. Therefore, when the mishnah says "exempt," it is not only an exemption from violating the oath, but also an exemption from a vain oath.
The argument of Rabbi Yehudah ben Beseira:
The mishnah notes that by logic there would be room to hold liable one who swore to fulfill a mitzvah, and this is indeed the opinion of Rabbi Yehudah ben Beseira. He derived it by a kal vachomer: if for an optional oath - something that involves no mitzvah and about which a person does not stand sworn from Mount Sinai, such as one who swore to throw a stone and did not throw it - he is liable, then an oath concerning a mitzvah, about which a person already stands sworn from Mount Sinai, should it not follow that he is liable for it?
The response of the Sages:
The Sages disagreed with him, as we saw at the beginning of the mishnah, and said that one cannot learn from an optional oath to an oath concerning a mitzvah. With an optional oath, such as throwing a stone, the choice is in the person's hands whether to throw or not to throw, and there is no mitzvah directing him one way or the other - and therefore in such a case the "no" is equivalent to the "yes," and the oath takes effect in both directions. This is not the case with an oath concerning a mitzvah, where even Rabbi Yehudah ben Beseira concedes that the "no" and the "yes" are not equal: even according to his view, one who swore not to put on tefillin and then did put on tefillin is exempt, for an oath does not take effect to nullify a matter of Torah law. And just as a person cannot swear against the Torah, so too his oath does not take effect regarding the fulfillment of a mitzvah of the Torah, about which he already stands sworn.