Optimal control problems are notoriously difficult to solve analytically or numerically except for limited cases of simple dynamics. Evolutionary algorithms are a promising method of solving various optimal control problems arising in practice since they do not require the expression of Lagrange's adjoint system and can easily implement the inequality constraints on the control variable. In this article, the evolutionary algorithm method is combined with the spline method so that the smooth control profile and switching time of bang-bang control could be obtained simultaneously. The optimal profiles obtained by the proposed method are compared with exact solutions if available. The proposed method could solve the problems only if there are only model equations and performance index functions, and even then the solution profiles are complicated. It is demonstrated that the evolutionary algorithm with the spline method can solve a wide range of optimal control problems including those of the bang-bang type.