This paper presents a linear programming approach for the optimal control of nonlinear switched systems where the control is the switching sequence. This is done by introducing modal occupation measures, which allow to relax the problem as a primal linear programming (LP) problem. Its dual linear program of HamiltonJacobi-Bellman inequalities is also characterized. The LPs are then solved numerically with a converging hierarchy of primal-dual moment-sum-of-squares (SOS) linear matrix inequalities (LMI). Because of the special structure of switched systems, we obtain a much more efficient method than could be achieved by applying standard moment/SOS LMI hierarchies for general optimal control problems.