Photochemical Heating of Dense Molecular Gas