Changes in the work function Phi of metal surfaces upon deposition of ultrathin oxide films have been studied by means of band structure density functional theory calculations. Four systems have been considered: MgO/Ag(100), MgO/Mo(100), TiO2/Mo(100), and SiO2/Mo(112). MgO films induce a decrease of Phi of 1 to 2 eV compared to the clean metal substrate; SiO2 and TiO2 induce an increase of Phi of about 0.5-1 eV. The reasons for this behavior are different: for TiO2 and SiO2 the work function increase can be explained with the classical model of surface dipole due to metal-to-oxide charge transfer at the interface. On MgO/metal interfaces, where the charge transfer is negligible, the shift is due to the compression of the metal electron density enforced by the oxide layer, with consequent change in surface dipole. The results suggest that by appropriately choosing the metal support and the oxide film one can design nanostructured materials with new properties.