Howdy there molypoley,
It sounds like your sound is intermittently dropping out and is very inconsistent. This should be pretty easily isolated to either software or hardware. I would start by quitting all the running apps on the device:
Force an app to close in iOS
1. Press the Home button two times quickly. You'll see small previews of your recently used apps.
2. Swipe left to find the app you want to close.
3. Swipe up on the app's preview to close it.
When you have done that restart the device and test the issue again:
iOS: Turning off and on (restarting) and resetting
If the issue persists, backup your device to iTunes, then restore it as new and verify that it works.
How to erase your iOS device and then set it up as a new device or restore it from backups
If it does, then restore your backup to either verify it still works and the software just needed reinstalled, or isolate the issue to the backup file itself.
I the issue persists after restoring as new then the issue is with the hardware and it will need to be serviced:
iPhone Repair and Service
Thank you for using Apple Support Communities.