Step 1: In the electromagnetic spectrum, the energy of a photon is linked to its frequency by \(E = hf\), where h is Planck's constant and f is the frequency.
Step 2: A higher frequency, or equivalently a shorter wavelength, always means a higher photon energy.
Step 3: Arranging the given radiations by increasing frequency and energy, infrared has the lowest energy among these four, followed by ultraviolet, then X-rays, and finally gamma rays, which have the shortest wavelength and highest frequency of all electromagnetic waves.
Since gamma rays sit at the very top of the electromagnetic spectrum in terms of frequency, they carry the maximum energy. The correct answer is option B.