We study the evolution of the Stellar Mass-Metallicity Relation and the Luminosity-Metallicity Relation by performing numerical simulations in a cosmological framework. We find that the slope and the zero point of the Luminosity-Metallicity Relation evolve in such a way that, at a given metallicity, systems were ∼3 mag brighter at z = 3 compared to galaxies in the local universe, which is consistent with the observational trend. The local Stellar Mass-Metallicity Relation shows also a good agreement with recent observations. We identify a characteristic stellar mass Mc ∼ 1010.2 M⊙h-1 at which the slope of the Stellar Mass-Metallicity Relation decreases for larger stellar masses. Our results indicate that Mc arises naturally as a consequence of the hierarchical building up of the structure.