The low (sub %) efficiencies so-far demonstrated for nonlinear optical down-conversion to terahertz (THz) frequencies are a primary limiting factor in the generation of high-energy, high-field THz-radiation pulses (in particular narrowband, multicycle pulses) needed for many scientific fields. However, simulations predict that far higher conversion efficiencies are possible by use of suitably-optimized optical sources. Here we implement a customized optical laser system producing highly-tunable trains of infrared pulses and systematically explore the experimental optimization of the down-conversion process. Our setup, which allows tuning of the energy, duration, number and periodicity of the pulses in the train, provides a unique capability to test predictions of analytic theory and simulation on the parameter dependences for the optical-to-THz difference-frequency generation process as well as to map out, with unprecedented precision, key properties of the nonlinear crystal medium. We discuss the agreements and deviations between simulation and experimental results which, on the one hand, shed light on limitations of the existing theory, and on the other hand, provide the first steps in a recipe for development of practical, high-field, efficiency-optimized THz sources.