How long should I eat bland foods if I have gastritis?

Long time. This probably takes weeks to heal because the therapy (h2 receptor blockers/antagonists, antacids) may be administered over a period of several weeks. Even after therapy, things like not taking nsaids and bland, restricted diet might have to be continued for a long time.