We develop a computational method for solving an optimal control problem governed by a switched impulsive dynamical system with time delay. At each time instant, only one subsystem is active. We propose a computational method for solving this optimal control problem where the time spent by the state in each subsystem is treated as a new parameter. These parameters and the jump strengths of the impulses are decision parameters to be optimized. The gradient formula of the cost function is derived in terms of solving a number of delay differential equations forward in time. Based on this, the optimal control problem can be solved as an optimization problem.