Previously I wrote this other post
about how to change system settings (like Airplane Mode) by directly manipulating the SQLite database file that stores them. It turns out that there's a better way.
You'll need a rooted device and USB debugging (aka. ADB) enabled.
To enable Airplane Mode:
settings put global airplane_mode_on 1
am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true
To disable Airplane Mode:
settings put global airplane_mode_on 0
am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false
This worked for me on Android 4.3 (actually it was CyanogenMod 10.2.1). Came really handy when I rebooted my phone, forgot to unlock it and a Tasker profile turned Airplane Mode on. In this state the OS wouldn't accept any PIN combination for unlocking the phone, so until Airplane Mode was on, I couldn't use the phone at all.
P.S.: your phone doesn't have to be rooted for this to work! Although on later Android versions each USB (ADB) connection has to be approved prior first use. So you'll need a computer that is already approved on the phone.