Immune checkpoint inhibitors, introduced in recent years, have revolutionized the treatment of many cancers. However, the toxicity associated with this therapy may cause severe adverse events. In the case of advanced lung cancer or metastatic melanoma, a significant number (10%) of patients treated with CTLA-4 inhibitor incur damage to the pituitary gland. In order to reduce the risk of hypophysitis and other severe adverse events, steroids may be combined with CTLA-4 inhibitor; they reduce toxicity, but they also diminish the anti-cancer effect of the immunotherapy. This trade-off between tumor reduction and the risk of severe adverse events poses the following question: What is the optimal time to initiate treatment with steroid. We address this question with a mathematical model from which we can also evaluate the comparative benefits of each schedule of steroid administration. In particular, we conclude that treatment with steroid should not begin too early, but also not very late, after immunotherapy began; more precisely, it should start as soon as tumor volume, under the effect of CTLA-4 inhibitor alone, begins to decrease. We can also compare the benefits of short term treatment of steroid at high doses to a longer term treatment with lower doses.