I am planning to apply for a PhD program and would like to request a letter of recommendation from a professor. However, I am quite hesitant about which way is better for me to make the initial request: asking the professor during the break of the class or just sending him an email?
My recommendation is definitely in person "after class". There are several reasons to do so. First, it is personal and you can iron out any details there and then. Second, the person you approach will have a face to go with any future e-mail conversations. Third, it is less likely a person will dismiss you in a direct approach than in an (impersonal) e-mail approach.
There are of course ways in which you can blow your hopes with a personal approach as well. Just be brief and to the point, try to be professional about it. If the person appears not to have time, ask if you can meet during an office hour or if an E-mail would be better. After all, you have just presented yourself and is now "a face".
There is of course nothing wrong with just sending an E-mail but I know from personal experience that I sometimes get mails from students who apparently have attended my classes but made no impression so I ask myself, who the ... is this? Not a great basis for a letter of recommendation. I personally also think that a personal approach shows more initiative and drive. All this is of course from the perspective that you actually can meet with the person without engaging in long distance travelling etc.
You could try doing both - first talk to him after class, and if he expresses interest, send a packet of materials by email (your resume, things you'd like him to include, maybe your transcript if it's good). It's good for him to have these things electronically because then the materials are harder to lose and he has a written reminder of your request.
An e-mail from someone you can't even remember is easy to reject, there's almost no emotions involved. Plus if he says yes, you still have to meet to talk about the details and write them down, or risk misunderstandings via e-mail. It's better in person.
During a break or after class there may be other students waiting to ask questions, or the professor may be in a rush, or any other such disturbance, it doesn't feel serious to me and you risk getting only half an answer or him telling you to set up an appointment.
Just go find him during the official office/consultation hours (whatever they're called in your country), or if he said you have to take an appointment first, then take an appointment but go discuss it in person.
Don't agree with other answers! I'd 100% prefer students to ask me by email. It gives more time to think about how to phrase the request properly, motivate it, and give details; and it gives more time to the professor to think about his/her answer.
The other answers say it's more personal to ask face to face and the professor may forget who you are unless they see you, that's a strange argument. If your professor doesn't remember you by name, don't bother ask him/her for a letter.