Stochastic thermodynamics provides a conceptual framework for describing the fluctuating behavior of small systems like colloids or biomolecules far from thermodynamic equilibriums but still contacted with a heat bath. In contrast to most literature focusing on the classical paradigm of Carnot engines, we herein study the optimal performance of the thermodynamic heat engine with a heat bath that periodically changes temperature, which is outside controllable by a time-dependent harmonic potential. Under reasonable assumptions on the control actuation, we derive the achievable upper bound for the maximal power and also the optimal control protocol. In addition, we also obtain the corresponding efficiency at maximal power, which only depends on the ratio of the minimal and maximal value of the temperature profile.