I've been told that its not safe because of the temperature difference, but I also know that people put whipped cream on stuff like hot chocolate, so why wouldn't it be safe to put cold foam on hot coffee?
There is no safety issue with adding cold milk foam to hot coffee. Coffee aficionados recommend against adding cold milk to hot coffee, because they suggest it compromises the flavor of freshly brewed coffee. Their recommendation is that any milk, foam or not, should be warmed, but it is not a food safety issue.
There's no plausible mechanism that would make it unsafe. It's usually impractical though, since milk foams better when heated. Steaming it automatically heats the milk, and most mechanical ways of doing it work best if you heat the milk first.
It's not quite cold foam on hot coffee, but one popular dessert in Italy is affogato. At its most basic, it is a scoop of vanilla ice cream topped with a shot of espresso, i.e. very cold milk product and very hot coffee served together.
You may be thinking of the reverse: pouring hot, steamed milk over ice. There is an idea floating around out there that this is dangerous because it creates conditions for harmful bacteria to grow:
“Pouring hot, steamed milk and foam over cold ice can allow for the growth of bacteria. Even though it’s a small risk, it’s still a risk.” 
As to whether this has any scientific grounding, I have no idea. Just passing on that some baristas hold this view, and I have seen at least one refuse someone who asked for steamed milk over ice. I myself am not worried, and love an iced capp from Wrecking Ball: