Optically and thermally induced molecular switching processes at metal surfaces