It depends.
If you just want *inside a task* to check if VPN is on or not you may use the following method (replace "flash" commands by you own code)
Vpn
A1: Run Shell [ Command:ifconfig Timeout (Seconds):0 Use Root:Off Store Output In:%out Store Errors In: Store Result In: Continue Task After Error:On ]
A2: If [ %out ~R (?m)^(ppp|tun) ]
A3: Flash [ Text:VPN is on Long:On ]
A4: Else
A5: Flash [ Text:VPN is off Long:On ]
A6: End If
But if you want to trigger a profile as soon as VPN is on, I don't have an working solution (unless using a polling approach which would be a very bad thing in term of performance and ressource usage)