In this paper, the design of a LQ regulator for linear switched systems in continuous time is investigated. From a relaxation of the optimal control problem, a Lyapunov based switching law is provided. Even if the subsystems are all unstable, the state feedback switching law can be applied subject to a positiveness condition. In any cases, the real cost is always upper bounded by the Lyapunov function value. The optimality of the switching law is also discussed and we prove that the switching conditions are optimal in some generic cases. This point explains why the obtained results over examples approach finely the optimal solutions. Finally, a design strategy is also given that extends the results to the cases where the subsystems are controlled linear systems.