Is it necessary to publish a research paper while pursuing MS?
The first question depends on your university's requirements. I think that it is sometimes required, but not universal. 

The second question might also depend on what sort of job you are interested in. Most jobs for MS graduates aren't especially research oriented, so, while it would be a plus, it might not be essential. 

But if your future is in academia, it is good to get started on research as soon as you can. 

I you have an advisor, consult him/her for advice on what you want to do in your future.