The 28-year-old singer-songwriter performed the single during Thursday's episode of the CBS late-night show following its release that morning.
Puth said he made "Girlfriend" a couple years ago but thought it was "too ahead of its time" at the time. He wrote the "'80s-esque Prince-y kind of electropop" track at a time when hip hop was dominating the charts.
"It just didn't feel right to put it out, so I kinda just kept it to myself for a long time," the star said. "I just think it's a perfect time for the world to hear this song."
Puth said he wrote "Girlfriend" in the hopes of his love interest hearing it.
"It's something you play for someone who's way out of your league. You just put it on in the background and you hope that they get the hint," he said. "Maybe that will help someone else, because it certainly didn't help me."
Puth also discussed his "surreal" experience working with Elton John. The pair collaborated on a song prior to the coronavirus (COVID-19) lockdown.
Puth met John at Craig's restaurant in Los Angeles and had the singer over to his house the next week. Puth said John remarked on how they "write very differently" but was willing to try.
"He sits down and plays the entire song that we wrote, it's three minutes and three seconds, he plays the entire thing," Puth said of John. "First take -- didn't do any more takes -- records the entire thing, and he's like, 'How about that?'"
"I've never seen anything like it," he added.
"Girlfriend" is Puth's first song of 2020. Puth released his second studio album, Voicenotes, in 2018.