There are two shutter curtains in a typical DSLR, a first/leading curtain & a second/trailing curtain. The camera starts with the first curtain blocking light from reaching the sensor. When you press the shutter release button, the first curtain moves out of the way and the sensor is illuminated. After the exposure time/shutter speed duration has elapsed, the second curtain covers up the sensor.
Here is a diagram of the operation of a two-curtain shutter.
When you use flash, the default is to fire the flash as soon as the first curtain is open. This is usually OK, but it causes problems if movement occurs
after the flash has fired. The problem is that the movement will appear in front of the moving subject, because the object's location is established at the beginning of the exposure duration by the "early" flash. This effect looks unnatural.
Flash units have an option called "Second/Trailing Curtain Sync". This will fire the flash just before the second curtain moves to block the sensor. This means that any movement that is captured occurs
before the main image's position is recorded with the "late" flash. This produces a more natural "trailing" effect.
The example of lights on a moving car at night is usually used, but I've picked a different subject purely to demonstrate the difference, rather than for artistic effect. Pentax K20D, smc Pentax-DA 16-45/F4 @ 16mm FL, 1.5s, F8, ISO 100 with a Sigma EF-530 DG Super flash unit.
If you want an example of trailing shutter sync flash with motion blur, look
here.
To remember when to use it, think "Trailing shutter sync for trailing motion blur"
Dan.