The d-rest is before the lagering period. If you can take gravity readings, you want to do the d-rest when you are about 8 points above expected OG. I tend to just use 1.020 as a rule of thumb, except for higher gravity lagers. If it is difficult for you to do a d-rest, another rule of thumb is to do it once the krausen has mostly fallen.
Many people say you don't always need to do a d-rest, and that's definitely true. But it's not always easy to detect diacetyl, and it can get worse over time. There is also absolutely no downside to doing one. A lot of brewers say they never do them, never do them, never do them...until they get a d-bomb dumper. Advanced brewers can probably ascertain by taste whether a d-rest is necessary or not--but I do one every time regardless.
Do your d-rest in the primary; some people do 48 hours but I always do a week at least; then rack it to your secondary or keg and lager it there for as long as you can stand to wait. A rule of thumb is a week per eight gravity points, but not everyone is that patient and frankly it's probably overkill anyway.
2012 Canadian Brewer of the Year