I’m assuming you use AOSP, the default keyboard. Here’s how I did it:
Step 1: Get your keyboard to show up on screen.
Step 2: Hold comma (assuming you use English (US) layout), and it will show a gear icon. Now, release.
Step 3: Click on Android Keyboard Settings (AOSP)
Step 4: Click on Text correction
Step 5: Click on the switch for Auto-correction.