When one eats cake with coffee, he of course recites two Berachot: "Mezonot" over the cake, and "She’ha’kol" over the coffee. (This assumes he drinks the coffee separately; if he dips the cake into the coffee, and does not drink the coffee on its own, then he recites only "Mezonot" over the cake, and this covers the coffee absorbed by the cake.) According to the standard rules governing the sequence of Berachot, a person in this case should first recite "Mezonot" and take a bite of the cake before reciting "She’ha’kol" and sipping the coffee. Given the rule that more specific Berachot precede less specific Berachot, it would certainly appear that the cake should precede the coffee in such a case, and this is, indeed, the ruling of Hacham Ovadia Yosef in his Yabia Omer.
However, Hacham Ovadia’s son, Hacham David, in Halacha Berura, posits a novel theory – that in such a case one should first recite "She’ha’kol" and sip the coffee before reciting "Mezonot" and taking a bite of cake. He explains that there is a minority view among the Poskim that when one drinks coffee with cake, the coffee is considered "Tafel" ("secondary," or "subordinate") to the cake, such that the coffee is covered by the Beracha recited over the cake. According to this view, since one’s primary intent is to eat, and the coffee is drunk only because the cake is dry, the coffee does not require its own Beracha, and it is included in the Beracha recited over the cake. Although Halacha does not follow this opinion, Hacham David asserts that it is preferable to avoid this Halachic dispute by first reciting a Beracha over the coffee and taking a sip, before reciting the Beracha over the cake. And although "Mezonot" always precedes "She’ha’kol," Hacham David notes the position taken by the Ritba (Rav Yom Tob of Seville, Spain, d. 1320), in a recently-published manuscript, that this rule applies only when one eats two foods requiring these two different Berachot, but not when one eats a food and drinks a beverage. In the latter case, according to the Ritba, there is no preferred sequence, and one may either partake first of the food or first drink the beverage. In light of this position, Hacham David reasons, it is preferable when eating cake with coffee to first recite "She’ha’kol" over the coffee and then recite "Mezonot" over the cake. Hacham David asserts that if his father had seen this position of the Ritba, he would have reached this same conclusion.
Of course, this is not the conventional opinion. Regardless, as for the practical Halacha, both views are valid, and one may choose which one to follow.
Summary: When one eats cake with coffee, the conventional practice is to first recite "Mezonot" and eat some cake, and then recite "She’ha’kol" and take a sip of coffee. According to one opinion, however, one should reverse the order, and first recite "She’ha’kol" and sip some coffee before reciting "Mezonot" and partaking of the cake. Both opinions are valid.