Praise be to Allah.
Swearing that one will be a disbeliever in order to make oneself do something or refrain from something is reprehensible speech, and it is not permissible.
Al-Bukhari (1363) and Muslim (110) narrated from Thabit ibn ad-Dahhak (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: Whoever swears deliberately and falsely that he belongs to a religion other than Islam is as he said.”
Abu Dawud (3258) and Ahmad (23006) narrated that Buraydah said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Whoever swears an oath and says ‘I have nothing to do with Islam’, if he is lying it will be as he said, and if he is telling the truth he will not return to Islam soundly.” Classed as sahih by al-Albani in Sahih Abi Dawud.
If he swore that he would become a disbeliever, intending it literally and meaning what he said, then he is a disbeliever, because he meant it.
But if he swore that he would become a disbeliever if he did something, so as to stop himself from doing it and make that thing off-putting to himself, then he did it, he does not become a disbeliever as a result of doing it, but he must offer expiation for breaking an oath (kaffarat yamin).
If he said that he would become a Jew, or a Christian, or a Zoroastrian, or that he would have nothing to do with Islam, or that he would become a communist if he did such and such; or he swore by Allah that he would stop doing something, and that if he went back to it then he would die as a disbeliever, and the like, then this is an oath, and he must offer expiation if he breaks his oath, but he does not become a disbeliever thereby, according to scholarly consensus, as was narrated by Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him), who said:
If he said that he would become a Jew or a Christian if he did such and such, or that if he did such and such he would become a disbeliever, and the like, then the leading scholars are agreed that if he breaks his oath, he does not become a disbeliever; rather he must offer expiation for breaking an oath according to Abu Hanifah and Ahmad, according to the well-known view narrated from him. According to Malik and ash-Shafa‘i, he does not have to do anything, unlike the case if he said, “If you give me the money, I will become a disbeliever.” In this case, he becomes a disbeliever on that basis; in fact he became a disbeliever immediately [as soon as he said these words], because he meant it and intended that he would become a disbeliever if that condition was fulfilled [and his oath was broken]."(Majmu‘ al-Fatawa 33/199).
Ibn ‘Allan (may Allah have mercy on him) said:
“then he is as he said” means: if he wanted to change his religion and was determined that he would do that if he did that thing [concerning which he swore that oath], then he becomes a disbeliever immediately, because deciding to disbelieve constitutes disbelief. But if his intention was to make sure that he would not do that thing, and he intended never to do the thing mentioned in his oath, then it is a sin and he must ask Allah for forgiveness for it."(Dalil al-Falihin (8/394); see also: al-Mawsu‘ah al-Fiqhiyyah 7/300-303).
See also the answer to question no. 174658 .
If he said that and then died:
- If he did not do the thing concerning which he swore that oath, then there is no blame on him and nothing is required of his heirs.
- If he did do it, and died before he could offer expiation for his oath, then his heirs must offer expiation on his behalf from his wealth (the estate).
It says in Mughni al-Muhtaj (6/192):
If someone dies owing expiation, then the least expensive option must be given from his estate. End quote.
And Allah knows best.