The Shulchan Aruch · Orach Chayim
אורח חיים תרפ״בOrach Chayim 682
Siman 682 of 697 in Orach Chayim — 3 se'ifim
הלכות חנוכהLaws of Chanukah· siman 682
Se’if 1א׳
כָּל שְׁמוֹנַת יְמֵי חֲנֻכָּה אוֹמֵר עַל הַנִּסִים בְּבִרְכַּת הַמָּזוֹן בְּבִרְכַּת הָאָרֶץ, וּבַתְּפִלָּה בְּבִרְכַּת מוֹדִים; וְאִם לֹא אָמַר, אֵין מַחֲזִירִין אוֹתוֹ וְעַיֵּן לְעֵיל סי' רצ"ד סָעִיף ד' וְה'; וּמִיהוּ אִם נִזְכַּר בְּאוֹתָהּ בְּרָכָה כָּל זְמַן שֶׁלֹּא הִזְכִּיר אֶת הַשֵּׁם, אֲפִלּוּ נִזְכַּר בֵּין אַתָּה לְהַשֵּׁם, חוֹזֵר. הַגָּה: יֵשׁ אוֹמְרִים כְּשֶׁשָּׁכַח עַל הַנִּסִּים בְּבִרְכַּת הַמָּזוֹן כְּשֶׁמַּגִּיעַ לְהָרַחֲמָן יֹאמַר: הָרַחֲמָן יַעֲשֶׂה לָנוּ נִסִּים וְנִפְלָאוֹת כְּשֵׁם שֶׁעָשִׂיתָ לַאֲבוֹתֵינוּ בַּיָּמִים הַהֵם בַּזְּמַן הַזֶּה בִּימֵי מַתִּתְיָהוּ כו' (כָּל בּוֹ), וּכְבָר נִתְבָּאֵר סִימָן קפ"ז סָעִיף ד'.
All eight days of Chanukah one says "For the Miracles" in the grace after meals in the blessing of the land, and in prayer during the blessing of thanksgiving. If one did not say it, one does not return [in order to repeat and make the proper insertion]. (See above chapter 294 paragraph 4 and 5). However, if one remembered while still saying the blessing, as long as one has not said the name of God [in the closing line of the blessing], even if one remembered between the words "You" and "God", one should return [and make the proper insertion]. Rema: There are opinions that if one forget "For the miracles" in the grace after meals, when one reaches "the merciful one", say: "May the merciful one make miracles for us just like You make for our forefathers in those days at this time, in the days of Matityahu etc."[Kol Bo] [and this was explained in chapter 187 paragraph 4]
Se’if 2ב׳
גַּם בְּמוּסָף שֶׁל שַׁבָּת וְשֶׁל רֹאשׁ חֹדֶשׁ צָרִיךְ לְהַזְכִּיר שֶׁל חֲנֻכָּה, אַף עַל פִּי שֶׁאֵין מוּסָף בַּחֲנֻכָּה.
Also in the musaf prayer on shabbat and Rosh Chodesh one must mention Chanukah, even though there is no musaf prayer on Chanukah.
Se’if 3ג׳
אֵין אוֹמְרִים: כְּשֵׁם שֶׁעָשִׂיתָ וְכֻלֵּי, אֶלָּא מְסַיֵּם: וְעָשִׂיתָ עִמָּהֶם נִסִים וּגְבוּרוֹת בַּיָּמִים הַהֵם בָּעֵת הַזֹּאת; וְיֵשׁ אוֹמְרִים שֶׁאוֹמְרִים אוֹתוֹ.
It is not said [as part of the text of "Al HaNisim"]: "Keshem Sheasita, etc" [Just as you did with our ancestors...] but ends the prayer by saying: "VeAsita Imahem Nisim Ugevurot, Bayamim Hahem, Baet Hazot" [ you did miracles and wonders with them, in those days, on these dates]. In any case, there are those who culminate as the formula raised above.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0