If you do too much, you won't know, you will just pass out and stop breathing. People don't realize it when they OD on intravenous heroin. They don't call 911 themselves. That's why it's always best to not use alone, or at least use where someone would find you if you passed out, like, say, in a bathroom where if you didn't come out within a few minutes someone would check on you.
It's always better to underdose than overdose. Some things you can do to reduce your risk of overdosing are to always do a small first shot whenever you have a new batch (even from the same dealer), whenever you're using in an unfamiliar environment (environment is a huge factor in tolerance, surprisingly, and you can OD on the exact same quantity of the same dope just from being in a different place/situation than usual), and whenever you haven't used in a while. Also don't use other CNS depressant drugs/alcohol close to when you use heroin, that is the biggest cause of ODs, mixing heroin with benzos or other CNS depressants.
As far as knowing how much you can safely dose, that's something that comes with practice and even then you can't be completely sure, so the best idea is really just to use reasonable amounts and not try to go for that "perfect high" where you're totally nodding out, since the margin between super high and dead is so thin.
If you mean how can you comfortably enjoy your high without worrying that you might go into serious respiratory depression if you nod off, well, think about the fact that serious respiratory depression is not something you can somehow prevent by staying alert/awake, and also if you are using IV heroin and no other drugs, signs of an OD normally happen within the first 10 minutes of injecting it.
Heroin should be like scuba diving: Always have a buddy.