Two-photon photoemission spectroscopy is employed to elucidate the electronic structure and the excitation mechanism in the photoinduced isomerization of the molecular switch tetra-tert-butyl-azobenzene (TBA) adsorbed on Au(111). Our results demonstrate that the optical excitation and the mechanism of molecular switching at a metal surface is completely different compared to the corresponding process for the free molecule. In contrast to direct (intramolecular) excitation operative in the isomerization in the liquid phase, the conformational change in the surface-bound TBA is driven by a substrate-mediated charge transfer process. We find that photoexcitation above a threshold hnu approximately 2.2 eV leads to hole formation in the Au d-band followed by a hole transfer to the highest occupied molecular orbital of TBA. This transiently formed positive ion resonance subsequently results in a conformational change. The photon energy dependent photoisomerization cross section exhibit an unusual shape for a photochemical reaction of an adsorbate on a metal surface. It shows a thresholdlike behavior below hnu approximately 2.2 eV and above hnu approximately 4.4 eV. These thresholds correspond to the minimum energy required to create single or multiple hot holes in the Au d-bands, respectively. This study provides important new insights into the use of light to control the structure and function of molecular switches in direct contact with metal electrodes.