Smoothing splines are widely used for estimating an unknown function in the nonparametric regression. If data have large spatial variations, however, the standard smoothing splines (which adopt a global smoothing parameter lambda) perform poorly. Adaptive smoothing splines adopt a variable smoothing parameter lambda(x) (i.e. the smoothing parameter is a function of the design variable x) to adapt to varying roughness. In this paper, we derive an asymptotically optimal local penalty function for lambda(x) is an element of C-3 under suitable conditions. The derived locally optimal penalty function in turn is used for the development of a locally optimal adaptive smoothing spline estimator. In the numerical study, we show that our estimator performs very well using several simulated and real data sets.