If a person eats a large quantity of "Pat Ha’ba’a Be’kisnin" (the precise definition of which will be discussed in a separate context), such as cake, then the cake is treated like bread, and thus requires Netilat Yadayim, the Beracha of "Ha’mosi," and Birkat Ha’mazon. The amount one must eat for the food to attain the status of bread is 216 grams, or approximately 7.5 oz.
Hacham Ovadia Yosef ruled that in such a case, the requirement to recite Birkat Ha’mazon after eating the cake applies on the level of Torah obligation, just as in the case of one who ate bread (in the amount that brings satiation). The practical importance of this point is that if a person in this situation cannot remember whether or not he recited Birkat Ha’mazon, then he must recite the first three Berachot. Since we deal with a Torah obligation, we must apply the rule of "Safek De’Orayta Le’humra" – that one must act stringently in situations of doubt involving a Torah law. Since eating 216 grams of cake requires reciting Birkat Ha’mazon on the level of Torah obligation, one must be stringent in a situation of doubt, and recite the first three Berachot of Birkat Ha’mazon (which are required on the level of Torah law).
Hacham Ovadia adds that in many instances, there is also a question whether the food indeed falls under the category of "Pat Ha’ba’a Be’kisnin," or if it might be considered bread. Sponge cake, for example, is considered "Pat Ha’ba’a Be’kisnin" according to some opinions, but according to others, "Pat Ha’ba’a Be’kisnin" includes only crackers or pastries with filling, such that sponge cake is considered ordinary bread. In some instances, then, when a person ate 216 grams of "Pat Ha’ba’a Be’kisnin" and then cannot remember whether he recited Birkat Ha’mazon, he is under a "Sefek Sefeka" ("double doubt"), and must certainly recite Birkat Ha’mazon. But in truth, as Hacham Ovadia acknowledges, this point is not even necessary, because reciting Birkat Ha’mazon after eating 216 grams of "Pat Ha’ba’a Be’kisnin" in any event constitutes a Torah obligation, and, as such, we must apply the rule of "Safek De’Orayta Le’humra," as discussed.
Summary: If one ate 216 grams (approx. 7.5 oz.) or more of cake or cookies, then he must recite Birkat Ha’mazon, just as if he had eaten bread. If, after eating, he cannot remember whether or not he recited Birkat Ha’mazon, then he recites the first three Berachot of Birkat Ha’mazon, just as he would if he had this doubt after eating bread.