We perform a second-order sensitivity analysis of the linear temporal stability of a parallel flow subject to small spanwise periodic modification. The need for a second-order analysis results from the fact that spanwise-periodic flow modifications have a quadratic effect on the stability properties of parallel flows (i.e. the first-order eigenvalue variation is zero). From a simple one-dimensional (1D) calculation we compute the second-order sensitivity operator, which allows us to predict the effect on stability of any small modification without computing the eigenmode correction. Comparisons with two-dimensional (2D) stability calculations of modified flows show excellent agreement and validate the method. From the second-order sensitivity operator we optimise the growth rate variation and compute optimal flow modifications, providing lower and upper bounds for the growth rate variation induced by any spanwise-periodic modification of given amplitude. We finally discuss under which conditions a spanwise periodic modulation is more efficient to stabilize/destabilize the flow in comparison to a spanwise homogeneous flow modification.