We have developed an optimal method to determine expansion parameters for flexible stencils in 2D scalar-wave finite-difference frequency-domain (FDFD) simulation. Our stencil only requires the involved grid points to be paired and rotationally symmetric around the central point. We apply this method to the transition zone in discontinuous-grid modeling, in which the key issue is designing particular FDFD stencils to correctly propagate the wavefield passing through the discontinuous interface. Our method can work in an FDFD discontinuous grid with arbitrary integer coarse- to fine-grid spacing ratios. Numerical examples are developed to determine how to apply this optimal method to discontinuous-grid FDFD schemes with spacing ratios of 3 and 5. The synthetic wavefields are highly consistent to those calculated using the conventional dense uniform grid, and the memory requirement and computational costs are greatly reduced. For velocity models with large contrasts, our discontinuous-grid FDFD method can significantly improve the computational efficiency in forward modeling, imaging, and full-waveform inversion.