Live mode uses the real API credentials for your real PayPal account.
Test mode requires the use of sandbox API credentials.

So, if you're going to switch between live and sandbox, you need to also re-enter the API credentials, else you'll get those 10002 Security Header Is Not Valid errors because you're authenticating against a non-existent account.