"The time of pitch is defined as the moment the pitcher’s movements commit him to deliver the ball to the batter...
A runner who advances while the pitcher is in contact with the rubber is considered to occupy the base last touched at the time the pitcher initiates his actual pitching motion to the batter. The pitching motion is defined as any movement which commits the pitcher to deliver the ball to the batter."
Thus, in the "foul ball" scenario above, the runner must have actually acquired second base prior to the pitcher beginning his motion in order to remain on second base immediately following the foul.