This paper studies the stabilization of optimal equilibrium profiles in nonisothermal plug-flow tubular reactors actuated by a heat exchanger that acts as a distributed control input. As a first result, we show that the heat exchanger temperature that achieves the minimal value of the steady-state reactant concentration at the outlet is the maximal allowed one. Then, a control strategy is proposed to reach these optimal equilibrium profiles. As main results, we prove that the control law stabilizes exponentially the nonlinear dynamics around the optimal equilibrium while it converges to the optimal heat exchanger temperature. In addition we show that the control law is optimal for some cost criterion of infinite-horizon integral type. Finally, the main results are illustrated with some numerical simulations.