We introduce a general scheme for calculating from first principles both the transverse-optical and longitudinal-optical infrared absorption spectra at surfaces or interfaces. A spatial decomposition of the spectra gives the evolution of the infrared activity across the considered system. Application to ultrathin oxides on silicon yields infrared spectra which reproduce the observed redshift of the high-frequency peaks for decreasing oxide thicknesses. This effect is shown to arise from the lengthening of the Si-O bonds in the substoichiometric oxide at the interface.