Elucidating the electronic structure of organic molecules in contact with a dielectric layer is essential to understanding and controlling many important processes, such as catalysis, photochemistry, and electroluminescence. However, this challenge calls for a detailed characterization of molecule-dielectric contacts on the atomic scale. Here, we employ scanning tunneling microscopy (STM) at low temperature (4 K) in combination with ab initio calculations to investigate the subnanometer-scale electronic states of photoactive molecules on a dielectric surface. For platinum and palladium octaethylporphyrin (PtOEP and PdOEP) adsorbed on few layers of NaCl on a metal substrate, our STM imaging of them in the energy gap between the frontier orbitals demonstrates their high sensitivity to the local environment, namely, adsorption site and applied voltage. Our calculations reveal that the states in this energy gap originate from combinations of molecular orbitals far from the Fermi level and that they are affected by the extent of molecule-surface partial charge transfer, which is tuned by adsorption site and voltage in the tunnel junction.