In this paper we address the problem of optimal switching for switched linear systems. The uniqueness of our approach lies in describing the switching action by multiple control inputs. This allows us to embed the switched system in a larger family of systems and apply Pontryagin's Minimum Principle for solving the optimal control problem. This approach imposes no restriction on the switching sequence or the number of switchings. This is in contrast to search based algorithms where a fixed number of switchings is set a priori. In our approach, the optimal solution can be determined by solving the ensuing two-point boundary value problem. Results of numerical simulations are provided to support the proposed method. c 2008 Elsevier Ltd. All rights reserved.