If the offense fails to move the football forward the required ten yards, they must turn the ball over to their opponent.
If the offense takes all four downs and fails to move the ball the required ten yards, the ball is turned over to the other team at that point on the field. That is, the defense now becomes the offense at the exact place where the offense has been stopped.