For YouTube Videos and other videos you will have to press home button and then swipe from bottom to pull up the control center. From there, swipe to left and tap on the play button and the audio of the that video will start to play in background.
You won’t have to worry about the audio getting stop because the audio will still run in background and you can listen to while using other apps.
There is a slight difference between audio and video. On audio when you will press home button from Safari then the audio will run in background while in case of videos you will have to press home button and then open Control Center by swiping from bottom and swipe to left side to access the music player screen and tap on play button and the audio of that video will run in background.