The Gemara brings a braysa, which says that if someone made a mistake and did not mention Rosh Chodesh in Shachris, he does not need to repeat Shemoneh Esrai because he can say it by Mussuf. And the conclusion of the Gemara is that this braysa is talking about b'tziybur - when he is davening with a minyan.
Rashi says that he does not repeat it because he hears it from the shliyach tzibur, but if he is b'yochid, he must repeat Shemoneh Esrai.
According to the Ayin Mishpat Ner Mitzvah, this is brought down l'halacha in Kuf Chuf Vuv - by hilchos shliyach tzibur sheta'a. [Not like Rashi, who indicated that we are talking about someone other than the shliyach tzibur, who is davening btzibur - not the sh'liyach tzibur himself.]
However, just a few lines later, the very last Gemara in the perek is about the halacha that a person does not repeat Shemona Esrai if he forgets Rosh Chodesh at Maariv because bais din is not mekadesh the chodesh at night. This is brought down l'halacha in Taf Chuf Bais - At Maariv you do not repeat Shemona Esrai, and by all other Tefilos you do repeat Shemona Esrai.
Is Tuf Chuf Bais only talking about a person who is not davening with a tzibur (like Rashi)? I don't see any indication in Tuf Chuf Bais (unless I missed something) that the halacha only applies if he is davening b'yochid.
And if so, where do we see brought down l'halacha that a person who is davening b'tzibur can rely on listening to the Shliyach T'zibur and the fact that he will say it in the next tefila?
Greetings, Reb Dovid. Regarding the Machlokes how to understand the Gemara, the BEHAG (as cited in Rashi), RAMBAM, RIF according to the RE'AH, RASHBA, RI, ME'IRI, and others learn that the Gemara is talking about a Shaliach Tzibur who made a mistake. He does not repeat Shemoneh Esreh since it would be too much of an inconvenience for the Tzibur to have to wait for him, plus he will be able to mention Ya'aleh v'Yavo in the next Tefilah.
The SHILTEI GIBORIM points out (as does the RASHBA and TUR) that all of the Rishonim argue with Rashi's explanation, and that his explanation does not read well in the Gemara, and therefore the Halachah is not like Rashi. This answers your second question.
As far as your first question, the Shulchan Aruch in OC 422 does not necessarily have to be talking about someone Davening by himself. Since it is discussing missing Ya'aleh v'Yavo during Ma'ariv , which has no Chazaras ha'Shatz, hearing Shemoneh Esreh from the Shaliach Tzibur does not apply.