All praise is due to Allah, and peace and blessings be upon our master, the Messenger of Allah.
Whoever swears an oath or makes a vow to abstain from something has a choice: if he wishes, he may keep to his vow, or if he wishes, he may offer the expiation of an oath (kaffārat yamīn). The Prophet (peace and blessings be upon him) said: “The expiation for a vow is the expiation for an oath.” Narrated by Muslim. This type of vow is called a nadhr al-lajāj (a vow made in stubbornness or anger).
If a person makes a vow and then forgets it, nothing is due from him, for forgetfulness is among the excuses that lift legal responsibility (taklīf) from a Muslim. This is based on the saying of the Prophet (peace and blessings be upon him): “Actions are judged only by intentions, and every person will have only what he intended.” [Narrated by al-Bukhārī]. There is no intention for the one who forgets or errs. It is also based on the report: “Indeed, Allah has pardoned for my Ummah mistakes, forgetfulness, and what they are compelled to do.” Narrated by Ibn Mājah and others, and graded authentic by Ibn Ḥibbān and al-Ḥākim.
It is stated in ʿUmdat al-Sālik (p. 243), one of the books of the Shāfiʿī school: “Whoever swears, [for example], ‘I will not enter the house,’ and then enters it forgetfully, ignorantly, under compulsion, or being carried, he does not break his oath.” And Allah Almighty knows best.