No, you do not have to pay for Apple Music if you have an iPhone, but you do need to have an Apple Music subscription to access the full range of features. When you first set up your iPhone, you will be prompted to sign up for a free three-month trial of Apple Music.
After the trial period, your subscription will automatically renew at the standard monthly price unless you cancel it.
While you can use the Apple Music app on your iPhone without a subscription, the features available will be limited. Without a subscription, you can still listen to your local music library and any playlists you have created, but you will not have access to the millions of songs available on Apple Music or any of the service’s other features, such as curated playlists, radio stations, and on-demand content.