If, in the middle of a brocha over a particular food, one suddenly remembers that he already made a brocha on that food, he may not change the ending to exempt another food. Since at the time of saying Hashem’s name he intended to finish the brocha one way, he may not conclude it another way. If, however, a similar scenario happens with a tallis (i.e. mid-brocha he realizes that he is exempt), he may change the brocha to cover his tefillin instead. This is because putting on tefillin is obligatory, whereas eating another food is arbitrary.
[משנ"ב ח, מא; ביאורים ומוספים דרשו, 61 ;וראה ס' וזאת הברכה עמ' 206'טו]