In this paper, we present an on-line real-time physics-based approach to motion control with contact repositioning based on a low-dimensional dynamics model using example motion data. Our approach first generates a reference motion in run time according to an on-line user request by transforming an example motion extracted from a motion library. Guided by the reference motion, it repeatedly generates an optimal control policy for a small time window one at a time for a sequence of partially overlapping windows, each covering a couple of footsteps of the reference motion, which supports an on-line performance. On top of this, our system dynamics and problem formulation allow to derive closed-form derivative functions by exploiting the low-dimensional dynamics model together with example motion data. These derivative functions and their sparse structures facilitate a real-time performance. Our approach also allows contact foot repositioning so as to robustly respond to an external perturbation or an environmental change as well as to perform locomotion tasks such as stepping on stones effectively.