The capability of materials for energy conversion and storage can be considerably extended by nanostructuring. The morphology and stability of a nanostructure depend crucially on the environmental conditions of fabrication and operation. It is therefore fundamental for energy applications to understand in detail how the environment influences these properties. In this talk, I will discuss atomistic simulations based on density functional theory aimed at investigating the formation and stability of nanostructures of oxides of platinum-group metals and of lithium in an oxygen-rich environment. These systems are relevant for fuel cells and lithium-air batteries, respectively. I will show that the thermodynamics of oxides is different when the nanoscopic size is taken into account and that this has consequences for their functionality. I will thoroughly compare the calculations with experimental results on oxidation state, morphology and functional behavior of nanostructures, and I will discuss open questions and future developments.