Although the equivalence of heat and work has been unveiled since Joule’s ingenious experiment in 1845, they rarely originate from the same source in experiments. In this study, we theoretically and experimentally demonstrated how to use a high-precision optical feedback trap to combine the generation of virtual temperature and potential to simultaneously manipulate the heat and work of a small system. This idea was applied to a microscopic Stirling engine consisting of a Brownian particle under a time-varying confining potential and temperature. The experimental results justified the position and the velocity equipartition theorem, confirmed several theoretically predicted energetics, and revealed the engine efficiency as well as its trade-off relation with the output power. The small theory–experiment discrepancy and high flexibility of the swift change of the particle condition highlight the advantage of this optical technique and prove it to be an efficient way for exploring heat and work-related issues in the modern thermodynamics for small systems.