NASA's rules, briefly
NASA images are generally not copyrighted in the US and may be used commercially with credit. Don't use the NASA insignia or logotype as part of your branding, don't suggest NASA endorses you, and ask before identifiable astronauts or staff appear in an ad. That is why NASA images carry an editorial flag here. Images credited to partners such as ESA or a university may belong to them: those say 'check the terms'.
Photos, composites and illustrations
Many space pictures are composites of several exposures, colourised from invisible wavelengths, or artist's concepts of things no camera has seen. They are labelled as illustrations where the source says so. For a science article, say which it is in the caption.