He says this in Derashos Chasam Sofer Derush L'Zayin Av, 5593 p. 334 columns 3 and 4 s.v. ונחזור.
ושוב התפלל כל יום ג' תפלות כי מוספי שבתות וי"ט אינם נחשבים כי אינם רחמים ותחנונים...מעתה צא וחשוב מי"ז ניסן א' מלא וא' חסר כלים תקי"ד תפלות ביה"כ אחר מנחה, היינו עם תפלה ראשונים שהתפלל במנחה יום י"ו ניסן, ועמד מרע"ה עתה ותיקן תפלת נעילה דיה"כ והיה תפילה התקט"ו שאם לא עכשיו אימתי
Moshe prayed 515 prayers to enter the land of Israel upon hearing he could not enter (Devarim Rabbah 11:10; Yalkut Reuveni, based on the numerical value of ואתחנן). Based on an idea he cites from his teacher the Hafla'ah (in his Panim Yafos, beginning of parshas Vaeschanan), the Chasam Sofer says that Moshe prayed the usual three times a day prayers, but specified this request each time. If you calculate from the 16th of Nissan (which he calculates is when Moshe was punished) three daily prayers (ignoring Mussaf prayers), you'll find on Yom Kippur after Mincha to be 514 prayers. It must be then that Moshe added an extra prayer, namely Neilah, which is how we get to the 515 prayers.
Personally, I'm not sure how it follows that since Moshe must have prayed an extra prayer at that time, that he instituted a formal extra prayer every Yom Kippur from then on. But that's what he says.