The Gemara in Masechet Rosh Hashanah (29) notes that the Torah uses two different terms in reference to the holiday of Rosh Hashanah. On one occasion the Torah calls this day "Yom Terua" – "a day of sounding the Shofar" – whereas elsewhere it refers to it as "Zichron Terua" – "a commemoration of sounding the Shofar." The Gemara explains that these different terms refer to two different situations. When Rosh Hashanah falls on a weekday, it is observed as a "Yom Terua," and the Shofar is sounded. But when it falls on Shabbat, then the holiday is only a "Zichron Terua" – a day when we mention the Shofar, but we do not sound the Shofar.
For this reason, the text of the Rosh Hashanah Amida prayer changes when Rosh Hashanah falls on Shabbat. Normally, in our prayers we refer to Rosh Hashanah as "Yom Terua," but when Rosh Hashanah falls on Shabbat, we change the text to "Zichron Terua."
The Shulhan Aruch (582:7) rules that if one mistakenly recited "Yom Terua" in the Amida prayer on Rosh Hashanah when it falls on Shabbat, he does not have to repeat the Amida, despite the mistake that he made. Several reasons are given for this ruling. Firstly, the reason why the Shofar is not sounded when Rosh Hashanah falls on Shabbat is out of concern that one might carry the Shofar through a public domain, in violation of Shabbat. However, an exception is made in a place with an authoritative Bet Din, as people in such communities are more careful, and thus the Shofar is sounded even on Shabbat. Therefore, at least in theory, Rosh Hashanah is a "Yom Terua" even when it falls on Shabbat, and if one mistakenly recited "Yom Terua" on Shabbat, he does not have to repeat the Amida. Moreover, there are those who suggest that although we do not sound the Shofar on Shabbat, in the heavens the Shofar is blown even when Rosh Hashanah falls on Shabbat, thus justifying the recitation of the term "Yom Terua" even on Shabbat.
A number of authorities (the Peri Hadash, and Rav Haim Palachi, in Mo’ed Le’chol Hai) assert that this applies in the reverse case, as well. If somebody mistakenly recited "Zichron Terua" when Rosh Hashanah falls on a weekday, he does not repeat the Amida, because the Rif (Rabbi Yishak of Fez, Morocco, 1013-1103) brings a view that one should always say "Zichron Terua," even on a weekday. Although Halacha does not follow this view, it may be relied on in a case where one mistakenly recited "Zichron Terua," and he thus does not repeat the Amida. This is the ruling of Hacham Ovadia Yosef, in his Hazon Ovadia – Yamim Noraim (pp. 82-83).
Summary: When Rosh Hashanah falls on Shabbat, we recite the phrase "Zichron Terua" in place of "Yom Terua" in the Amida prayer. Nevertheless, if one recited "Yom Terua" instead of "Zichron Terua" on Shabbat, or, conversely, if one recited "Zichron Terua" on a weekday, he has nevertheless fulfilled his obligation and does not have to repeat the Amida.