What happens on atomic and molecular level?
Is this true also for non-metals and metalloids?
The color changes are usually thin oxide layers on the metal's surface. These layers reflect light, which causes nice looking interference fringes from partial reflection from the front and back of these layers. The colors that get reflected depend on the thickness and the angle of the light, which causes iridescent optical effects (mother of perl has a similar mechanism, but with many layers of changing optical density).
The formation and stability of these layers depend on the metal and conditions under which it is exposed. Titanium can produce very pretty oxide layers that last a long time at room temperature after their production. This is commonly being use for jewelry. Stable layers on silver and certain annealed steel parts like watch springs can also be observed. I am not aware the lead, tin or zinc produce such layers or that they have mechanically stable oxide layers. Aluminum makes a thick, porous oxide layer which doesn't seem to be too visible on its own, except when it's really thick and becomes a dull grey. This is commonly used in anodization to make hard protective aluminum surfaces. Aluminum oxide anodization can be readily dyed, printed etc. and is technically very useful. Another technically useful process that works on many metals is chromate conversion coating, which does produce thin, colorful films, as well. Not too long ago highly toxic hexavalent chromium has been regulated, though, and only trivalent chromate can now be used for most technical applications. I think certain aerospace applications are still exempt.
On gold and platinum these layers don't form, at all, I believe, at least not using oxygen, alone.
The details of formation, thickness as a function of heating etc. is a question for the chemists and material scientists. Physically they will change thickness depending on the treatment, which will change their optical appearance. The strongest optical effects are being cause by layers that have approximately the thickness of half a wavelength or a full wavelength of light. The layers also need to have the highest possible index of refraction, which is a density problem, and they should be of roughly uniform thickness, which requires controlled process parameters.
If you are looking for scientific literature on the subject, the topic is usually discussed under "optical properties of thin films", whereby a thin film can mean such an oxide layer on metals or glass, a film of oil on water or any other structure that forms a thin, nearly homogeneous optical layer. Your topic does belong into physics with regards to optical properties, but the technical question of how to make these layers is more of a material science question. I don't know if there is an ideal forum for that.