We present an approach of deterministic phase engineering that can enable the rational design of optical Fano resonances with arbitrarily pre-specified lineshapes. Unlike all the approaches previously used to design optical Fano resonances, which fall short of designing the resonances with arbitrary lineshapes because of the lack of information for the optical phases involved, we develop our approach by capitalizing on unambiguous knowledge for the phase of optical modes. Optical Fano resonances arise from the interference of photons interacting with two optical modes with substantially different quality factors. We find that the phase difference of the two modes involved in optical Fano resonances is determined by the eigenfrequency difference of the modes. This allows us to deterministically engineer the phase by tuning the eigenfrequency, which may be very straightforward. We use dielectric grating structures as an example to illustrate the notion of deterministic engineering for the design of optical Fano resonances with arbitrarily pre-specified symmetry, linewidth, and wavelengths.