Agree with Standback and Jason Baker.
If you aren't sure of the source of a quote, you should say so, not just give your best guess without qualification.
(Actually, I'd say that for any fact you mention. If it's debateable whether Thomas Jefferson was really influenced by Herbert Fromme when writing the Declaration of Independence (a claim I just made up), you should say "Some theorize that ..." or whatever, not just flatly say it's true.)
It's fairly conventional with debatable quotes to give the quote and then instead of saying "-- Carl Sagan" or whomever, to put "attributed to Carl Sagan", or when really debateable, "sometimes attributed to Carl Sagan". In less formal writing, people sometimes say, "I think it was Carl Sagan who said that ..." If you are just quoting some statement you consider clever or interesting and who said it is not particularly important, a couple of words like this to indicate that you are not sure of the source should be plenty.
If you are actually relying on the expertise or authority of this person to make an important point, then if it's questionable I'd go to a little extra effort to make that clear. To take an extreme example, if you are claiming that the Foobar Party is a bunch of racists based on an outrageous statement made by their leader, but there is some debate whether he really said it, I think it would be very unfair to baldly say, "As their leader said ..." In such a case you should at the least make clear that he denies he ever said this or whatever the story is. If it's really important you should say what the evidence is either way. I've read articles where someone adds a quick qualifier like, "As their leader is reported to have said ...", which strikes me as dishonest: they stick in the "reported" so they can protect themselves if challenged, while trying to give the reader the impression that this is an established fact. I doubt anything this extreme applies to your Sagan/Bab-5 quote, but if in context you're relying on the reputation or authority of Mr Sagan to make some important point, and not just that you think this was a cute comment, then proper attribution becomes important.
Side note: The fact that a statement was made by a character on a television show does not necessarily mean that the writers of that show invented it. They may be quoting someone else -- whether Sagan in this case or whomever. No one expects a TV show to give proper attribution of quotes. I'm not saying the writers of that show didn't invent this quote, I have no idea. Just considering the possibility.