A class of optimal control problems of hybrid nature governed by semilinear parabolic equations is considered. These problems involve the optimization of switching times at which the dynamics, the integral cost, and the bounds on the control may change. First- and second-order optimality conditions are derived. The analysis is based on a reformulation involving a judiciously chosen transformation of the time domains. For autonomous systems and time-independent integral cost, we prove that the Hamiltonian is constant in time when evaluated along the optimal controls and trajectories. A numerical example is provided.