Formation of an electric dipole at metal-semiconductor interfaces