Windows phone by default switches off the WiFi when the screen gets timed out or locked. Below are the steps which will help you keep the wifi always turned on. Beware that this will consume more battery.
- Navigate to settings.
- Tap WiFi.
- Tap advanced.
- Select the checkbox “Keep WiFi on when screen times out”.