Swearing is not one of the things that invalidate wudoo’.
But it is mustahabb for the one who commits a sin to do wudoo’, because wudoo’ expiates for sins, as is proven from the Prophet (peace and blessings of Allaah be upon him).
It was mentioned by al-Shiraazi in al-Muhadhdhab (2/73) and Ibn Hazm said in al-Muhalla (1/241), narrating from ‘Aa’ishah, Ibn Mas’ood and others among the Sahaabah (may Allaah be pleased with them), that it is enjoined to do wudoo’ after speaking bad words.
Al-Nawawi said in al-Majmoo’ (2/72):
The correct view is that it is mustahabb to do wudoo’ after saying bad words, such as backbiting, malicious gossip, lying, slander, false speech, immoral speech and the like. The purpose of that is expiation for sins, as is proven in the ahaadeeth, but that is not obligatory.
Ibn al-Mundhir said in his books al-Ishraaf and al-Ijmaa’
: The scholars are unanimously agreed that it is not obligatory to do wudoo’ after saying bad words such as backbiting, slander, false speech and the like… al-Shafaa’i, Ibn al-Mundhir, al-Bayhaqi and our companions quoted as evidence the hadeeth of Abu Hurayrah (may Allaah be pleased with him), according to which the Prophet (peace and blessings of Allaah be upon him) said: “Whoever says in his oath ‘By al-Laat and al-‘Uzza,’ let him say ‘Laa ilaaha ill-Allaah,’ and whoever says to another, ‘Come and gamble with me,’ let him give charity.” Narrated by al-Bukhaari and Muslim. End quote. i.e., he did not tell him to do wudoo’.
Shaykh al-Islam Ibn Taymiyah said in al-Ikhtiyaaraat (p. 15):
It is mustahabb to do wudoo’ immediately after committing the sin.