The song has to have come first and inspired the movie or show. No theme songs, and no movies/shows that happen to have the same title as the song but the two otherwise have nothing to do with each other.
“Convoy” by CW McCall
“Harper Valley PTA” by Jeannie C. Riley
“Take This Job and Shove It” by David Allen Coe
“Rudolph, The Red-Nosed Reindeer” by Johnny Marks
The John Wayne movie Green Berets was based on the bestselling Ballad of… – there was also a book, apparently – it’s not clear where the book comes in the chronology.
Several Christmas movies/TV specials came from songs:
“White Christmas” by Irving Berlin (the song was introduced in the vastly superior “Holiday Inn”)
“Grandma Got Run Over by a Reindeer”
“Frosty the Snowman”
There were also some composer biographies that were named for songs they wrote:
“Till the Clouds Roll By” (Jerome Kern)
“Three Little Words” (Bert Kalmer and Harry Ruby)
“Night and Day” (Cole Porter)
“Yankee Doodle Dandy” (George M. Cohan)
And there’s also “The Gambler” (Kenny Rogers song made into a TV movie).
“Everyone Says I Love You” (also Kalmer and Ruby) inspired a Woody Allen movie of that name (at least to some degree).