I don't know if you can single out defense. I think more knowledge and technology has come out of NASA than the Pentagon.
NASA and defense spending are closely related. Despite appearances the moon shots were military in nature. NASA is currently testing scramjets but this type of aircraft will first be used to deliver bombs. NASA has a more socially acceptable goal than killing people but otherwise NASA is largely the same thing as military research.