According to J.W. Rinzler's excellent "The Making of Star Wars: The Empire Strikes Back" (reproduced here on Yahoo Movies) the line was largely the result of a back-and-forth conversation between Harrison Ford and the film's screenwriter Irvin Kershner. At first the line was written as “Just remember that, ‘cause I’ll be back.”, followed by "Don’t worry about this", followed by just "I'll be back", finally followed by the iconic "I know".
It's hard to say whether Ford was inspired by Bowie but it's quite easy to see how the line evolved over time rather than being inspired by a single leap of Ford's imagination:
“I think she ought to just say, ‘I love you,’ as I’m passing by her,”
Ford suggests to Kershner. Later in the conversation, he makes the
change to his own line, saying, “If she says, ‘I love you,’ and I say,
‘I know,’ it’s beautiful and it’s acceptable and it’s funny.”
So it’s true that the iconic line was penned by Ford, but it wasn’t
improvised on the spot: It was hashed out with Kershner before the
shoot. Ford also wanted to add a line of reassurance to Leia
—something like “Don’t worry about this” — which eventually became his
saying to Chewbacca, “You have to take care of her.” Han Solo’s final
scripted line, “I’ll be back,” ended up on the cutting room floor,
because Kershner wanted to make it clear that Han Solo might not
survive the carbon freeze. “You can’t [reassure her] because you don’t
know whether this is the end or not,” the director said to Ford.
Ironically, that tender moment resulted in a fight between Ford and
Carrie Fisher, who was annoyed that her co-star made changes to their
scene without her input. When it came time for Han and Leia to profess
their love, the two actors still weren’t speaking. “Harrison is a very
fine actor. I regarded that scene as entirely his, which is why I gave
him so much opportunity to tell me how he thought we should treat it,”
Kerschner explains in Rinzler’s book. “That led to a little tension
with Carrie.”
When Kershner put his first cut of The Empire Strikes Back together,
executive producer George Lucas pushed back against the new dialogue,
fearing that the audience would laugh at Han’s line. In a 2010 Vanity
Fair interview, Kershner said that Lucas insisted on doing two preview
screenings, one with Han Solo’s scripted line (which Kershner had also
shot) and another with Ford’s version. “At the first preview in San
Francisco, the house broke up after Han Solo said ‘I know,’” Kershner
recalls. “When the film was over, people came up and said that is the
most wonderful line and it worked. So George decided not to have the
second screening.”