You typically learn it in high school. Middle school math is typically pre-algebra, although you may dip your toes in algebra when you're in 8th grade if you're taking an advanced class or something.