This is a situation that should not happen. It is not a setting, so there are three options:
1. You are accidentally turning on airplane mode, which is most likely. Get your hands out of your pocket if your phone is in there.
2. A software issue: please perform a hard reset (volume up, down, hold power until you see the Apple logo)
3. A hardware issue: please contact Apple if 1. and 2. are not the case.