When you ask, “When does it become necessary,” that word *necessary* has at least two connotations. The first connotation centers on the necessity to practice forgiveness simply because it is good to do so; it is virtuous. The second connotation of the word *necessary* centers on your well-being, on your health.
Let us start with the first issue. Because forgiveness is a virtue and because it is always good to practice the virtues (in balance with other virtues), then it follows that whenever you are treated unjustly, and whenever you are motivated to do so, it is then important to forgive. Is it necessary? Yes, if your goal is to grow as a virtuous person (growing in goodness and love, for example). Is it necessary from the viewpoint of society—demanded, in other words? No, society does not demand our forgiveness and so your forgiving is not *necessary* in that you must do so or face some kind of penalty.
Now let us focus on the second meaning of *necessary,* the context in which your health may be compromised. If you are feeling resentment and deep anger is starting to affect your level of energy, your concentration, and your sense of happiness (even a little), then it is time to forgive. Is it necessary? For good health, psychological and physical, yes. We have found no better remedy than forgiveness to the disquiet that can visit us following unjust treatment.
Your final question dichotomizes forgiveness and justice. You seem to assume that you have to choose either forgiveness or justice. You can and should exercise both at the same time. Forgive the person, for example, who is insensitive to you and correct him. As you forgive, the correction is likely to be more gentle than if you approach him as you are deeply angry.