External stimuli-controlled phase transitions are essential for fundamental physics and design of functional devices. Charge density wave (CDW) is a metastable collective electronic phase featured by the periodic lattice distortion. Much attention has been attracted to study the external control of CDW phases. Although much work has been done in the electric-field-induced CDW transition, the study of the role of Joule heating in the phase transition is insufficient. Here, using the Raman spectroscopy, the electric-field-driven phase transition is in situ observed in the ultrathin 1T-TaS2. By quantitative evaluation of the Joule heating effect in the electric-field-induced CDW transition, it is shown that Joule heating plays a secondary role in the nearly commensurate (NC) to incommensurate (IC) CDW transition, while it dominants the IC-NC CDW transition, providing a better understanding of the electric field-induced phase transition. More importantly, at room temperature, light illumination can modulate the CDW phase and thus tune the frequency of the ultrathin 1T-TaS2 oscillators. This light tunability of the CDW phase transition is promising for multifunctional device applications.