A JPEG is a file can get infected. However, in order to activate the virus, the file must be run. As the JPEG file is an image file, it will not be executed as long as the image is not processed by any other type of program.
Hence, if the image is executed by a program alike a library or a database, the system can get infected.