It can seem daunting to ask a teacher for a recommendation, but remember that your teachers are among your biggest supporters and they want you to succeed.
The best way to ask is to simply ask. Find a time when your teacher isn't busy and ask them directly. Don't go with friends, and try to avoid emailing. Be sure you have any information your teacher may need to write the recommendation and give them plenty of time to complete it.