we know that
density = mass/ Volume
During change of temperature , the value of mass of the metal remains constant.
we also know that the volume of the metal change as the temperature is changed since Volume depends directly on temperature .
from the above formula , we see that , density is inversely related to the volume of metal. hence as the temperature of metal is changed, the volume changes which in turn change the density of the metal. hence the density of piece of metal change on changing the temperature.