This article explains how to set up Find My (or its predecessor Find My iPhone) on your iPhone, iPad, or iPod Touch running iOS (or iPadOS) 13 or later.
How to use Find My on iPhone and iPad | Apple Support
The option to set up Find My is part of the initial iPhone setup process. You may have enabled it then. If you didn't, follow these steps to enable it.
Tap Find My. (In earlier versions of iOS, tap iCloud > Find My Phone to turn on the feature.)
If you want to let friends and family know where you are, turn on Share My Location on the Find My screen. This optional setting is not required to find your phone.