Generally it happens right away. The muscles in your body sometimes take a few hours to stiffen up, but that doesn't happen with your pupils. They dilate as soon as your nervous system stops being able to control them.
That said, death isn't a switch. You aren't "on" one second and "off" the next. Dying is a process, and different parts of the body shut down at different times, and not always in the same order depending on what exactly causes your death. Your pupils may go fixed and dilated before your heart stops beating and respiration stops, or it may occur after.
Checking for fixed and dilated pupils is one of the things they used to look at to determine if death has occurred (along with checking your heartbeat and respiration). It's not something that occurs hours later. Your pupils may remain reactive shortly after your heart stops, but they won't remain that way for too long.