I have gastritis, hyperacidity. When gas comes up pain upper chest. Release pain when gas goes through mouth. Why.?

It's gas. Increase gas formation in the stomach, and therefore belching up gas, has a number of causes. Aerophagia (literally eating air) can be caused by eating too fast, not chewing food well before swallowing, smoking, anxiety, certain foods, carbonated beverages. Avoid all of these, and you will finds less of the problem: think, chew, chew, chew, eat slowly and in a relaxed atmosphere.
See details. It sounds like you may have reflux. Get off of Ibuprofen as this makes it much worse.Msee a GI specialist if you have not done so already try a med such ss Prilosec (omeprazole)! daily.