I think by definition you're going to get a lot of info to your question, and therefore a lot of filler and probably some bs. Your question is one step more specific than "how do I race a criterium?". If the factors in deciding when to attack were concrete, they'd have been published 50 years ago.
The best riders out there simply attack until they break their opponent's legs. It can be on flat courses, hilly courses, whatever. When I go racing, the same individuals are dictating virtually every race. If you're one of them, then you don't need to ask this question. If you aren't one of them (I'm not), then you probably should not attack - instead, you should probably wait till a break containing these dominant racers is just up the road (usually under a 10 second gap) and the field looks a bit haggard. Jump across and pray. I've succeeded in finishing in the break just once doing this but I've been in a lot of breaks which eventually came back. It's worth a try.
But if you want a more specific answer, one that isn't quite so cynical, keep reading 🙂
Do you fare well in field sprints? Are you peloton astute so that you are reasonably confident you'll be in, say, the top 5 with 200 meters to go (which really means 3rd through 5th)? Or do you have dedicated teammates who will deposit you there? Then the answer is to never attack, simply follow and wait for 200 meters to go. A good sprinter is very, very hard to beat in a sprint. Even if the sprinter doesn't win, the sprinter can typically place top 10 or so. Sprinters will roll the dice with every field sprint and hope their number comes up. Jimmy Casper (Cofidis) is not an overwhelming favorite in field sprints yet he got one in a spectacular field sprint this year in the Tour. He also "lost" all the other sprints.
On the other hand, is your sprint lacking the edge necessary to win an all out field sprint? Do you have teammates who will assist you (block, leadout, chase)? Then have your teammates attack one after another till the whole field is falling apart and then have one of them lead you out on your attack. If you are solo, ride super conservative, don't even pedal if you can help it, keep your heartrate at practically resting level, and then wait for a big move to get brought back. Then go for it. If you're confident of your skills, do it before 10k to go. In the last few laps of the race it's very difficult to escape those who, with their team, have waited that long for a field sprint. The racers who come to mind are those like Jelle Nijdam (sp?), Ekimov, or Vinikourov in last year's final stage.
You'll have to factor in opposing teams as well as opposing racers.
You should be more conservative if: there is a team known for its ability to close major gaps quickly; there are a number of strong sprinters supported by their (possibly not as capable) teammates; you are not feeling great; your equipment puts you at a disadvantage (aero wheels can be worth 2+ mph in a break).
You'll want to be more aggressive if: there is a dominant team (typically dominant in numbers) who can't chase well; the strongest riders are individuals with no teams (so they'll probably join your break); there is a course obstacle which favors you (hill, wind, rain, dirt, etc); you have very good aero wheels (Specialized/HED, ZIPP, Cosmics, Boras); you are feeling very good; your feeler attacks take a while to get brought back.
Hope this helps
cdr