If one utters the name of Hashem in vain, they should say ברוך שם כבוד מלכותו לעולם ועד immediately afterwards and preferably without interrupting in between.
If one said ‘ברוך אתה ה and then realized they said it in vain, they should continue by ending with למדני חוקיך. If one already said אלקי and before saying נו realized it was in vain, they should continue with ישראל אבינו מעולם ועד עולם, and in all cases say בשכמל”ו.