The gemara tells a story where Dovid HaMelech was digging the שיתין for the beis hamikdash that bring the water down to the depths and was unsure whether he can erase Hashem's name to prevent the waters from flooding the world. Achitofel taught Dovid that a Kal V'chomer can be made from a Sotah, if to bring peace between a husband and wife the name of Hashem can be erased, then certainly to prevent the water from flooding the world it can be erased.
There seems to be a major question on this gemara. Why do we need a kal v'chomer from Sotah, it should be a simple halacha that pikuach nefesh pushes off all issurim in the Torah? It is fair to assume that flooding the entire world would be an issue of pikuach nefesh, so it should have been obvious to Dovid that the name of Hashem can be erased to preven that?
I recall seeing in the sefer of Rav Peretz Steinberg on the Rambam that the issur of erasing the name of Hashem is connected to avoda zara because the torah commands us to destroy avoda zara and then says לא תעשון כן לה' אלקיכם. Since it is connected to avoda zara, there would be no heter of pikuach nefesh. That is why Achitofel had to darshan a special limud from Sotah to permit it.
I would suggest a different answer. Surely pikuach nefesh would permit the name of Hashem to be erased. The problem was that Dovid held like the opinions in Yoma 85b that only definite pikuach nefesh pushes off issurim, but safeik pikuach nefesh does not (which the gemara considers to be the advantage of וחי בהם because only that source would teach that even safeik pikuach nefesh is docheh issurim). Dovid knew that it wasn't clear whether erasing the name of Hashem by throwing the piece of clay into the water would be an effective method of stopping the flood. It was only a safeik and therefore he held it could not be done. However, Achitofel introduced a kal v'chomer from Sotah. By Sotah the right to erase Hashem's name to bring peace is also only a safeik. If she is indeed guilty it will not bring peace, yet it was permitted because of the chance that she is innocent and the erasing of Hashem's name will restore their shalom bayis. This is very meduyak in rashi - לעשות שלום בין איש לאשתו- לבדוק את הסוטה ואם טהורה היא יהא שלום ביניהם, only if she is actually innocent will it bring peace. Therefore, learning a kal v'chomer from sotah would be an effective way to show that even for a safeik of restoring peace the name of Hashem could be erased. That is why we need the source from Sotah and can't rely on the standard pikuach nefesh approach.
************************
On another note- there is a major historical flaw in the story. Achitofel died after advising Avshalom and Avshalom preferring the advice of Chushai Ha'archi, which happened prior to Dovid purchasing the land for the Beis Hamikdash from Aravna HaYevusi. So, when Dovid was digging the שיתין, Achitofel should have been long dead. See Rashi in Makos 11a.