The efficient use of Type Ia supernovae (SNIa) for cosmological studies requires knowledge of any parameter that can affect their luminosity in either systematic or statistical ways. Observational samples of SNIa commonly use the metallicity of the host galaxy, Z_host, as an estimator of the supernova progenitor metallicity, Z_Ia, that is one of the primary factors affecting SNIa magnitude. Here, we present a theoretical study of the relationship between Z_Ia and Z_host. We follow the chemical evolution of homogeneous galaxy models together with the evolution of the supernova rates in order to evaluate the metallicity distribution function, MDF(Delta Z), i.e. the probability that the logarithm of the metallicity of a SNIa exploding now differs in less than Delta Z from that of its host. We analyse several model galaxies aimed to represent from active to passive galaxies, including dwarf galaxies prone to experience supernova driven outflows. We analyse the sensitivity of the MDF to uncertain ingredients: IMF, star-formation law, stellar lifetime, stellar yields, and SNIa delay-time distribution. There is a remarkable degree of agreement between the mean Z_Ia in a galaxy and its Z_host when they both are measured as the CNO abundance, especially if the DTD peaks at small time delays, while the average Fe abundance of host and SNIa may differ up to 0.4-0.6 dex in passive galaxies. The dispersion of Z_Ia in active galaxy models is quite small, meaning that Z_host is a quite good estimator of the supernova metallicity. Passive galaxies present a larger dispersion, which is more pronounced in low mass galaxies. We discuss the use of different metallicity indicators: Fe vs. O, and gas-phase metallicity vs. stellar metallicity. The results of the application of our formalism to a galactic catalogue (VESPA) are roughly consistent with our theoretical estimates. (abridged)