Yes, most modern smartphones allow users to charge their phones while listening to music. However, this practice can have an impact on the battery life of the phone, as using the phone while charging increases power consumption. In order to extend the battery life, try to avoid turning the volume too high while charging or performing high-load operations on the phone.
If your phone has a 3.5mm headphone jack, then you can listen to music with the headphones while charging, and the charging and headphone jack are separate and not affected.
If your phone doesn't have a 3.5mm headphone jack, no, you can only use Bluetooth headphones, or buy a connector converter.