This paper concerns the stochastic optimal control problem of switching systems with delay. The evolution of the system is governed by the collection of stochastic delay differential equations with initial conditions that depend on its previous state. The restriction on the system is defined by the functional constraint that contains state and time parameters. First, maximum principle for stochastic control problem of delay switching system without constraint is established. Finally, using Ekeland's variational principle, the necessary condition of optimality for control system with constraint is obtained.