The pain in the anus can be due to fissures, hemorrhoids or due to infection. It could also be due to an abscess. Infected piles is another possibility. At times such a pain is due to compression of spinal nerves. Infection with herpes simplex virus can also be another cause. You need to consult a colorectal surgeon. If hemorrhoids alone is the cause of pain and they do not respond to conventional therapy, they need to be excised. Also, Excess wind or gas can be due to swallowing more air, chemical reactions in digestion, more of sulfites in diet producing hydrogen sulfide gas (juices, molasses, yellow dye in ready made food stuffs, and red wine), inflammatory bowel disorder, food with high sugar content, food allergies, food poisoning, and certain food items (cabbage, raddish, peas beans etc ) produce more amount of gas. So, if this is reduced, pain due to passing gas will reduce.
Please consult your doctor. Take care!