The loopOut Expression

/**
* Replace type with one of the following values:
* "cycle" - this will repeat your animation from the beginning
* "pingpong" - alternates back and forth between keyframes
* "offset" - similar to cycle, only this will offset the values by the original
* "continue" - carries on the animation with the same velocity as the last keyframe 
*/
loopOut(type);

Example usage:

/**
* If a position property has two keyframes and this expression applied
* then when the time marker gets to the last keyframe it will
* then repeat the animation from the first keyframe
**/
loopOut("cycle");

More advanced examples:

Loop back and forth between two keyframes in After Effects

Apply the following expression to a property with at least two keyframes

loopOut("pingpong");

Only loop the last two keyframes of an animation

To only loop back and forth between the final two keyframes of an animation, you need to use the optional numKeyframes value like so:

loopOut("pingpong", 1);

Only loop the last three keyframes of an animation

To loop between the last three keyframes, you need to use the optional numKeyframes value and set it to (3 - 1 = 2)

loopOut("pingpong", 2);

Only loop the last n keyframes of an animation

Where n is the number of keyframes you want to loop between, set the second value to (n - 1)

/**
* For example: 
* If you want to loop between the last 4 keyframes the second value would be:
* 4 - 1 = 3
**/
loopOut("pingpong", 3);