When I was in graduate school my group found a major flaw in another group's work, and another group found a flaw in one of our papers. Beware that it's worth it to be sensitive about these issues- academia tends to be a small world, and you don't want to hurt people's egos or make enemies. Everyone makes mistakes, even in published and peer-reviewed papers. Bear in mind that once a peer-reviewed paper is published with a methodological flaw it becomes a failure of the entire community rather than a failure of that author.
I think the most productive way to handle this is to first contact the authors of the paper directly. If you feel as though you've found an error then you should be able to provide specific evidence or (for theoretical work) a counter-example to some proposed theorem. Approach them gently, and remember that you might be the one in error or that the error might be a simple like an unstated assumption. If the authors are responsible academics then you will have a dialogue with them that identifies the error or points out the flaw in your argument. If your claim is substantiated then it may be an opportunity to publish a joint correction or they might opt to retract their paper, depending on the severity of the problem. This is how good peer-reviewed science is supposed to work.
However, if the authors are unwilling to talk then and you feel like you need to push the issue then you'll have to escalate. Get in touch with the editor of the publication, but be sure you can substantiate your claims of an error in a way they'll understand and agree with. If they determine that you are correct then they may unilaterally retract the paper or provide the authors a chance to publish corrections. Depending on the severity and circumstances of the issue it may be appropriate for you to publish your own analysis of the topic.
Done correctly, finding a published flaw can be a great way to start a new relationship or collaboration with other people intensely interested in the same topics as you are. If you allow them to fix the problem with their published work in a way that allows them to save face they will be grateful. If you make a public debate out of the issue or go above their head to the publication editors too quickly you'll engender some bad feelings. If you make a public fuss about something and you end up being wrong then you'll look like a stupid jerk. Remember that academia is a small world and your reputation will follow you, so think about how you'll be perceived.
Above all else just remember that the purpose of the exercise is to correct the scientific record and you should be OK.
Edit: I wanted to echo John's comment to another (now deleted) post, which is that the probability that you are wrong or have misunderstood the paper is very high. Let the paper sit for a few days, and then read it again carefully. If you're still convinced there's an error then go to your adviser or a colleague and ask them to review your analysis. If everyone agrees that there is an error then it is time to humbly approach the authors.