סימן מג סעיף ז
אִם לְאַחַר גְּמַר הַסְּעוּדָּה קֹדֶם בִּרְכַּת הַמָּזוֹן שׁוֹתֶה קַאפֶע כְּדֵי לְעַכֵּל הַמָּזוֹן שֶׁאָכַל, צָרִיךְ לְבָרֵךְ עָלָיו בְּרָכָה רִאשׁוֹנָה, כִּי מַה שֶּׁהוּא בָּא לְעַכֵּל אֵינוֹ נֶחְשָׁב מִצָּרְכֵי הַסְּעוּדָּה. וּמִכָּל מָקוֹם טוֹב לְבָרֵךְ עַל מְעַט סֻכָּר בִּרְכַּת שֶׁהַכֹּל לִפְטוֹר אֶת הַקָּפֶה (עַיֵּן חַיֵּי אָדָם ומגן אברהם סִימָן קע"ד).
If, after you finish the meal, you drink coffee in order to digest the food, before you recite the Birkas Hamazon, you have to say a berachah prior to drinking it, because anything eaten to help digestion is not considered part of the meal. Nevertheless, it is best to say the berachah of Shehakol on some sugar, and with that exempt the coffee.
תנא דבי אליהו כל השונה הלכות בכל יום מובטח לו שהוא בן העולם הבא שנאמר הליכות עולם לו אל תקרי הליכות אלא הלכות (נדה ע"ג.)