Switching linear models can be used to represent the behavior of hybrid, time-varying, and nonlinear systems, while generally providing a satisfactory trade-off between accuracy and complexity. Although several control design techniques are available for such models, the effect of modeling errors on the closed-loop performance has not been formally evaluated yet. In this paper, a data-driven synthesis scheme is thus introduced to design optimal switching controllers directly from data, without needing a model of the plant. In particular, the theory will be developed for piecewise affine controllers, which have proven to be effective in many real-world engineering applications. The performance of the proposed approach is illustrated on some benchmark simulation case studies.