Most have a "battery saver" option that automatically does this (among other things) once the battery charge level reaches something under 15%.
On my most recent phones it's 10%, and you can either choose to have this happen automatically or to have the phone present a dialog where you then allow battery saver to kick in.