This letter concerns the optimal control of a continuous-time dynamical system via continuous and discrete-valued control variables, where the objective functional also accounts for state-independent switching costs. The class of mixed-integer optimal control problems (OCPs) is interpreted as a bilevel problem, involving both switching times optimization, for a given sequence of modes, and purely continuous optimal control. Additionally, an original nonconvex formulation for the switching costs is introduced, in terms of cardinality, inspired by sparse optimization and compressed sensing techniques. We then adopt proximal algorithms to solve the resulting bilevel OCP with composite objective function. An efficient routine for evaluating the proximal operator is developed. Two examples are numerically solved via a proximal gradient method, discussed and compared with the literature. Although this letter focuses on switched linear time-varying dynamics and quadratic cost functionals with a specific formulation of the switching costs, the proposed approach may also apply to more general mixed-integer OCPs.