In special relativity, mass energy and momentum are all rolled into the 4-momentum vector. Energy, which is not invariant under the change of frame, is one component of this vector.
The correct/most useful definition of mass in special relativity was at one time a little controversial and due to E = mc[sup]2[/sup], sometimes ‘mass’ is used as a synonym for ‘energy’, however these days ‘mass’ usually means ‘rest mass’ which is the norm (the length, if you like) of the 4-momentum vector and is invariant under a change of frame.
The 4-momentum of a system is the sum of the 4-momenta of its constituent parts and conservation of 4-momentum means that the 4-momentum vector of a closed system doesn’t change with time.
As the 4-momentum doesn’t change with time neither does its components (if you don’t change frame), so this implies conservation of total energy. Also as you when you sum vectors in a given basis, the nth component of the sum is just the total of the nth components, the total energy of the system in a frame is the sum of the energies of its constituent parts.
For rest mass, the conservation of 4-momentum also implies the total rest mass of a closed system doesn’t change. However the length of the sum of a set of vectors is not necessarily equal to the sum of the lengths of those vectors the total rest mass of a system is not necessarily equal to the sum of the masses if its constituent parts (as a result of the slightly quirky nature of spacetime geometry the total rest mass is greater than or equal to the sum of the rest masses).
In other words conservation of mass in special relativity only works if you use mass as a synonym for energy or if you define total mass in terms of the total 4-momentum rather than summing masses.
As we’re talking about the Universe though we’re in the realm of general relativity. In general relativity 4-momentum is rolled into a tensor called the stress-energy tensor. Because in general relativity the stress-energy tensor is coupled to the geometry of spacetime, global conservation of energy and mass become very slippery concepts, which should not be taken to always apply.
You should not therefore expect to find a useful global conservation law for energy and/or mass in all general relativistic cosmological models. However thanks to the assumption that the Universe is very ‘regular’ on large scales, the cosmological stress-energy tensor is comparatively very simple. At any given time the stress-energy of the Universe can be described simple by its mass density and pressure. ’
Matter’, which is any particles whose mean speed (weighted by energy) is small compared to c (e.g. atoms, electrons, protons, most particles with mass) has a pressure that is very close to zero. ‘Radiation’, which is any particle whose mean speed is c or close to c (e.g. photons and high-energy neutrinos) has a pressure that is close to one third their energy density. Due to Hubble red-shift in an expanding Universe, the energy density of radiation falls off much quicker than the energy density of matter. The result being in the current era the energy density of matter is several orders of magnitude larger than the energy density of radiation.
There are also thermodynamic considerations, however outside of the early Universe matter converting to radiation and radiation converting to matter does not make a significant difference to the energy density of matter.
The OP’s question then doesn’t have an easy answer as transfer of energy density between matter and radiation is not the only thing (or even the most significant thing) that alters the ratio of the two energy densities.