Assuming you are have carefully checked that there really are serious errors, the best course of action would be to contact the authors of the paper first. Maybe they can explain subtle details, not clearly described in the paper, that explain everything. Of course it is important to be nice: It is very well possible that everything appeared to be correct with the knowledge at the time the paper was published. Or that it is you who misinterpreted the methods (possibly because the paper was a little vague). And even if there are errors: nobody is perfect. So please be nice.
It is possible that the authors wish to collaborate with you to correct the errors, leading to a shared publication: a win-win situation. I have seen this happen more than once.
If this does not work for some reason you can consider contacting the editor, who may or may not be interested in correcting the errors. That will be up to the editor.
Depending on your specific case, it may also be possible to do some experiments yourself and publish your findings, referencing the paper with the errors and correcting them.
However, if the errors are minor, the result is "unimportant", or you are not too sure that there really is a mistake that needs correcting, you could also decide to simply ignore the paper. There are plenty of bad and/or unimportant papers out there and frankly, they do not deserve the attention even if it is to correct mistakes.
Note: I have partly copied from my own answer to a different, related question.