There is no sure way to differentiate between a hyperrealistic painting, a photorealistic rendering or a photograph.
(If the painter / 3D artist does not give it away by using unrealistic lights / light paths.)
While it is extremely hard to accomplish, it is possible to paint or render something that is extremely hard to distinguish from "the real thing". I have seen things that looked uncanny to my eye that were real photographs and I have seen things that I seriously believed to be real that were done in a VFX department.
The easiest way to tell if a JPEG is a photo or not is to look at its EXIFs - if they include a camera model, you can conclude that it is an actual photograph. However, one can easily write any EXIF information in any file - or delete it all together.
The only other way I can think of are particles - what 3D-people call "light scattering", a.k.a dust in the air, or fumes. The other thing that is almost impossible to accomplish is realistic-looking hair.
Another thing that sometimes gets hard are highly specular materials like Gold - however, I have seen multiple almost-perfect gold-shaders by now.
All of this can - and most certainly will - change in the future. Even today, if you look at showreels of renderers like V-Ray or Houdini's Mantra, you certainly will have a hard time to see what's what. As computing power increases, Bi-Directional Path-Tracing will become available (as in: not blocking you from using your computer for a week or two) to a broad public.
Full disclosure of experience: I took both my BSc. and my MSc. in post-production and have done a lot of compositing and 3D-stuff. And although I am far away from being a decent 3D artist, even I can make something extraordinary close to reality within a day or two (taking rendering out of account, of course).