a class of linear systems subject to sudden jumps in parameter values is considered. To solve this class of stochastic control problem, we try to find the best feedback control law depending both on the measurable output as well as the mode of the system. A gradient flow based algorithm is derived for this problem. It is shown that an optimal solution can be successfully computed by finding the limiting solution of an ordinary differential equation which is given in terms of the gradient flow associated with the cost function. Several important properties are obtained. A numerical example is solved.