Optical manipulation of ferroelectric polarization is a promising method for potentially ultrafast and remote polarization switching without electrodes. Here, we report optical ferroelastic and ferroelectric switching by UV irradiation in epitaxial BaTiO3 thin films grown on a SrTiO3-buffered Si substrate. The pristine BaTiO3 film is in the tetragonal ferroelectric phase with both in-plane and out-of-plane ferroelectric polarization. After irradiation by a 325 nm UV laser, the polarization is mainly out-of-plane indicating ferroelastic switching. Moreover, all initial downward polarized domains have switched to upward, thus showing ferroelectric 180°-domain switching. After irradiation the film exhibits mainly a single up-oriented polarization and as a result, the irradiated regions exhibit an enhanced piezoelectric response. We propose that the observed ferroelastic and ferroelectric switching is triggered by additional strain/stress fields generated by internal electric fields arising mainly from the spatial charge carrier separation after photoexcitation. These strain/stress fields add up to the Vegard strain field and to local heating, which induce defect motion and a final state with full strain relaxation. This optical switching enables remote manipulation of ferroelastic and ferroelectric domains in BaTiO3 films on silicon. Moreover, UV illumination appears as a potential postdeposition treatment to heal defects and obtain a strain-free epitaxial layer.