Someone counts the correct day of Sefiras HaOmer but then thinks he made a mistake, so he immediately "corrects" himself and counts the wrong day. Does his second (incorrect) counting, which was made toch kedai dibur of the first, undo his first correct count so that in order to fulfill the mitzvah he would have to count again? In other words, can toch kedai dibur be "mvatel" something that was said correctly and thereby prevent a mitzvah fulfillment that depends on a specific statement being said?
Halichos Shlomo quotes Reb Shlomo Zalman Aurbach's handwritten tshuva as saying it seems that the person has fulfilled his obligation with the first counting.
This is found in chapter 11 halacha 5.
ספר ספירת העומר כהוגן, וסבר שטעה וחזר בו תוך כדי דיבור וספר שלא כהוגן, מסתבר שיצא בספירתו הראשונה.
In the dvar halacha section there the author offers an important point:
ואף לפי מש"כ במק"א (ראה הליכות שלמה תפלה פ"ז סי"ג בארוכה) לדון דמהני חזרה תוכ"ד מכוונה לצאת, שאני הכא דהחרטה היתה בטעות, ולכן מסתבר דיצא.
So the important point is that a wrongful regret will not retroactively dissolve his resolution to have fulfilled his requirement, whereas a regular regret would work.
As you mentioned in your question, the crux of the issue is whether Toch Kedai Dibur is an absolute rule that undoes the previous statement in all situations, or if it is a tool that one could be used to correct something for one's benefit but not for harm.
It seems that it's a Machlokes about the nature of Toch Kedei Dibur. According to R' Elyashiv and R' Chaim Kanievsky (Sefer Hilchos Chag Bechag Sefiras Haomer 6:11), Toch Kedei Dibur is a tool that can only be used to help the speaker, not harm him. As a result, saying the wrong phrase after the correct one for Sefiras Haomer does not ruin the correct Sefira (although as a precaution, one should repeat the correct Sefira without a Bracha).
It seems like there are other opinions that hold Toch Kedei Dibur is an absolute power and undoes the previous statement in all scenarios, even to the detriment of the speaker (possibly the opinion of R' Shlomo Zalman Auerbach*). In this case, if one had in mind during the Bracha to say the wrong count, then 'accidentally' said the correct count, and 'corrected' himself to the wrong count, it would seem that he did not fulfill the counting at all, and would need to recount (probably with a Bracha).
However, even according to the latter opinion, there is an additional scenario by Sefiras Haomer that one could fulfill their obligation. If one did have in mind during the Bracha to count the correct day, and said the correct count, then 'corrected' himself to the wrong count Toch Kedei Dibur, he has fulfilled his obligation (I believe this is the case that is quoted in @user6591's answer above).
*Note: the above answer is based on my understanding of footnote 67 of the Dirshu Mishna Berura on Mishna Berurah 489:32. Unfortunately, I was not yet able to access the primary sources quoted in the Dirshu, so my answer is only based on my understanding of the Dirshu footnote.
I want to take as basis the answer of @DanF. I think that with contextualization, the answer to the case of the OP can be found through it. We see in the Tur 489 that the Raavia siman 526, (see in the link the whole text) compares the Beracha on the Sefira to Beracha on food (1). His nusach was to include the count into the Beracha. See here line 10
על ספירת העומר שהיום שבוע אחד ויום אחד
So following the nushach of Beracha of the Raavia, the suggia of error in Berachot (masechet Berachot 12a) is entirely relevant. If the Beracha is wrong, there is nothing, no Beracha and not Sefira.
Regarding the issue of an error about Beracha on foods, there are two main versions in the Text of the Gemara. Rashi says that the Gemara treats about a person who says the right Beracha, but at the time he said the Name of G-d, the intention was to say the wrong Beracha (פתח אדעתא...). The Rif said that the problem is different. He said the wrong Beracha and next the right Beracha (פתח בד... לסיים בד..). The Raavad rejects the rational of the girsa of Rashi because the cavana isn't so relevant for the beracha. The Gemara left the problem unsolved. For this unsolved problem, the Rif ruled by leniency, the Beracha is valid (followed by Bet Yosef OC 209). The Avi Ezri rules lechumra, in name of Rabenu Tam (Raavia Siman 38 left column, third line), and he follows the Girsa of Rashi. The Bet Yosef OC 489 quotes the same din in the name of Mordechai and says that Sefirat Haomer is a Mitsva Deorayta and even according to the poskim they are lenient in berachot for foods, here, they need to be stringent. The Bet Yosef rules as other Rishonim that Sefirat Haomer is Derabanan.
For the case he said right beracha and corrected wrong, the girsa of our Gemara didn't ask, not in the Girsa of Rashi and not in the Girsa of the Rif reported by the Rosh. But the Rif cited in Baal Hamaor (and the girsaot Sefarad reported by the Raavad on the Baal Hamaor) report the question of the Gemara differently. He brings a cup of bier, and begins right but ends wrong "bore peri Hagafen" is the question. See here Baal Hamaor, Raavad and Ramban. The Baal Hamaor rejects it because the Gemara says below that the chitum, the signature is the most important. And here the chitum is wrong. The Baal Hamaor follows the line of the Rif that the issue is correction when saying the Beracha. The Baal Hamaor decided this Girsa is wrong. There is no such question, the beracha is not valid obviously.
The Ramban in Milchamot explains the safek:
שכבר השלים ברכתו כהלכה וחזרה בטעות שחזר וסיים שלא כראוי לא הויא חזרה לפסלה או דלמא אפילו בזו בתר חתימה אזלינן ולא יצא
Since he finished his beracha correctly, what he said afterwards is not a correction to make it not valid, or, even if wrong, a correction cancels the first beracha and he is not yotse for the bier.
The Rashba says this reasoning is so strong that he cancels the girsa of the Geonim. He cancels as the Baal Hamaor but for an opposite reason. . And the Rashba concludes:
אלא פתח בדשיכרא וסיים בדחמרא מאי? וזה דבר רחוק מאד שיהא הפסד בתוספת שהוסיף לאחר שסיים ברכתו, ואפילו אמר לאחר מכן כמה דברים.
The case is that he said a right Beracha and corrected it by a right Beracha. The Rashba rejects this Girsa, because it is not questionable. It is obvious that a right beracha cannot be altered by further additional words.
Following this we can get a conclusion. In the case he counted the omer right and corrected wrong, he is Yotse, for the Rashba but not for the Baal Hamaor. And Ramban rules leKula as the Rashba because of Safek berachot Lehakel. All this assuming, as the Raavia that the count is a part of the beracha.
Note: For us the count is not a part of the Beracha, because we have not the same nusach as the Raavia. So, I am a little surprised that Shulchan Aruch quoted the suggia from the Raavia.
וכתב עוד אבי העזרי: היכא דפתח ואמר: "ברוך אתה י"י אלהינו מלך העולם" אדעתא דלימא "היום ארבעה", שהוא סבור שהם ארבעה, ונזכר וסיים בחמש והן חמשה, מי אזלינן בתר פתיחה, וכיון דפתח אדעתא דלימא ארבעה לא נפיק, או דלמא בתר חתימה אזלינן, וכדין חתים ונפיק?
אי נמי איפכא, הם ד' ופתח אדעתא דלימא ארבעה, וטעה וסיים בה', מי אזלינן בתר פתיחה ונפיק, או בתר חתימה ולא נפיק? ומסתברא דבתרווייהו לא נפיק, דבעיא פתיחה וחתימה ודאי.
See O.C. 489:5 which directly addresses your situation. Mechaber says that this is fine and you don't need to repeat the bracha. However, see Mishna Berurah commentary #32 which seems to indicate that since you ended with the wrong day, you would have to repeat the bracha.