Controlling the shape and position of moving and pinned droplets on a solid surface is an important feature often found in microfluidic applications. However, automating them, e.g., for high-throughput applications, does rarely involve model-based optimal control strategies. In this work, we demonstrate the optimal control of both the shape and position of a droplet sliding on an inclined surface. This basic test case is a fundamental building block in plenty of microfluidic designs. The static contact angle between the solid surface, the surrounding gas, and the liquid droplet serves as the control variable. By using several control patches, e.g., like done in electrowetting, the contact angles are allowed to vary in space and time. In computer experiments, we are able to calculate mathematically optimal contact angle distributions using gradientbased optimization. The dynamics of the droplet are described by the Cahn-Hilliard-Navier-Stokes equations. We anticipate our demonstration to be the starting point for more sophisticated optimal design and control concepts.