In this paper, we analyse an optimal control problem over a finite horizon with a stochastic switching time, assuming that the two optimal control problems present in its two stages have a particularly simple form called linear state. It is well known that linear state optimal control problems can be solved easily using the HJB equation approach and assuming that the value function is linear in the state. Unfortunately, this simplicity of solution does not extend to the problem with stochastic switching time. We prove that a necessary and sufficient condition for the problem to maintain a linear state structure is to assume that the hazard rate of the switching time depends only on the temporal variable. Finally, assuming that the hazard rate is constant, we completely characterise the solution of the obtained linear state optimal control problem.