The simple answer is don't exercise until the pain or inflammation is gone. You can exercise through "discomfort" but you need to recognize the difference between discomfort and pain.
Obviously the length of how long you should wait will changed based off of what was actually injured. Tendons take months to heal while muscles typically take weeks due to the increased blood flow that muscles receive.
The key when coming back from an injury is to watch for inflammation. The best way to combat inflammation is with ice and rest. Once that starts to subside then light stretching in the injured area will help the rehab process. Ultimately you know your body better than anyone else so be honest with yourself and if pain still resides in the area then don't exercise it and in time you will recover.