This article addresses the design and control of optimal scan trajectories, which is important in applications such as the imaging of nano-scale surface phenomena using Scanning Tunneling Microscopes (STM), quick-return mechanisms and cams used in manufacturing, and general repeating processes. In this article we pose the problem of designing the output trajectory for a scanner such that the input energy is minimized. The problem is solved by fist integrating optimal control techniques with a model-based inversion approach. After this integration, the input-energy for the entire scan is then minimized to solve the optimal scanning problem. Additionally, the method is applied to highspeed scanning of an STM, which is a key tool in emerging nanotechnologies. Simulation and experimental results are presented to illustrate the technique and its advantages.