The stabilization and robustification of a time-delay system is the topic of this paper. More precisely, we want to minimize the H2 norm of the transfer function corresponding to this class of linear time-invariant input-output systems with fixed time delays in the states. Due to the presence of the delays, the transfer function is a nonrational, nonlinear function, and the classical procedure which involves solving Lyapunov equations is no longer applicable. We therefore propose an approach based on a spectral discretization applied to a reformulation of the time-delay system as an infinite-dimensional standard linear system. In this way, we obtain a large delay-free system, which serves as an approximation to the original time-delay system, and which allows the application of standard H2 norm optimization techniques. We give an interpretation of this approach in the frequency domain and relate it to the approximation of the nonlinear terms in the time-delay transfer function by means of a rational function. Using this property, we can provide some insight in the convergence be- haviour of the approximation, justifying its use for the purpose of H2 norm computation. Along with this, the easy availibility of derivatives with respect to the original matrices allows for an efficient integration into any standard optimization framework. A numerical example finally illustrates how the presented method can be employed to perform optimal H2 norm design using smooth optimization techniques.