When will peroxide form?
From Greenwood and Earnshaw's excellent book Chemistry of the Elements:


  When the metals are burned in a free supply of air the predominant product depends on the mtal: $\ce{Li}$ forms the oxide $\ce{Li2O}$ (plus some $\ce{Li2O2}$), $\ce{Na}$ forms the peroxide $\ce{Na2O2}$ (plus some $\ce{Na2O}$) [...]


In general, formation of inorganic peroxide salts in this fashion doesn't appear to be especially favorable for other metals, at least by comparison to the variety of other oxides possible. Sodium's peculiar preference seems anomalous to me, especially given that the lattice energy for the oxide is higher (albeit slightly). This may be a function of the availability of oxygen, which is roughly $21\%$ in air, and is certainly temperature-dependent as well.

As for organic substances, formation of peroxide linkages is possible from a variety of functional groups and using various reagents. Ordinary $\ce{O2}$ will form peroxide bonds with various substrates via radical mechanisms, especially under photochemical conditions. Carboxylic acids react with $\ce{H2O2}$ to form peroxyacids. These are just two examples that come to mind, and numerous others exist.