I had neck sprain yesterday after which I took medicine for the same and I got acidity y is that so?

NSAID. My guess is you took an NSAID (ibuprofen, Naproxen etc). This type of medication can irritate the stomach and worsen acid production by blocking prostaglandin production, which, among other roles, provides protection to the stomach.
What did you take? Nsaids like Ibuprofen can cause hyperacidity when taken on an empty stomach, so make sure you take them with food in your stomach. You can also take Prilosec or a similar stomach medication to help. If not better, you need to be seen.
Acid can be a result. Certain pain medicines called nsaid's can result in increased acidity. If you need to take these regularly, you should take additional medicine to help protect your stomach lining. These medicines decrease the acid production in your stomach.