If you thought everything was going okay, but then had a really hard time in the exam, don't wait until progress reports or midterm grades are handed out. Waiting until after your grade comes out shows a lack of initiative; if you know you've done poorly -- especially if there's a good reason for it -- you should bring it up right away. Not only that, but term grades often can't be changed once they're entered into the system. (This also goes for assignments from the semester/quarter before.) If you are in this situation, try improving your grade for the upcoming marking period. Ask for extra-credit work so that you can shift your point average. If you want to talk your teacher and potentially challenge a grade you have received you need to understand the system they are using, how this influences grades and the limitations it imposes. Do they use a grading curve? Was it an especially high-performing class? Knowing these things can help you understand the process behind the grading of your papers. Your ability to question your grade is a lot more straightforward if the test was one which had objectively correct or incorrect answers. An essay question where answers are open to at least a degree of interpretation can be much more complicated and harder to dispute. In these cases you have to remember that the person marking is not a computer and subjectivity plays a part in their responses. In the case of an essay question, you can ask your teacher to go through your answer with you. Reading your essay together will give you the opportunity to understand in more detail how it was graded. Whether it's because you are making a good effort in class or you had a stumble along the road, you need a good reason in order for this to work. Don't try to blag it on the spot. Whatever you might think, your teacher isn't that dumb. If you are experiencing personal problems that have contributed to your grade, don't be afraid to talk to your teacher about it. Calmly and professionally say what you believe is wrong with your grade. Present other tests and assignments that demonstrate what you're capable of, and suggest the solution you think is reasonable. Be convincing and confident, but don't assume to know more or better than your teacher. Find good assignments to use as examples or backup. If you can demonstrate that your low score was a fluke and shouldn't drag down your entire grade, you stand a much better chance of getting it changed. If the problem was that you had an unreliable teammate in a group project, don't blame it all on him/her or you'll seem like a bad team player. Instead, say that if you'd given him/her extra help, you wouldn't have done as well on your half of the project, and that it's not fair to get a bad grade because of somebody else's work.

Summary:
Approach your teacher before you get the grade. Understand the grading system. Think about what kind of exam it was. Identify the reasons why you may deserve a better grade. Make your case.