We consider the valuation of credit default swaps (CDSs) under an extended version of Merton's structural model for a firm's corporate liabilities. In particular, the interest rate process of a money market account, the appreciation rate, and the volatility of the firm's value have switching dynamics governed by a finite-state Markov chain in continuous time. The states of the Markov chain are deemed to represent the states of an economy. The shift from one economic state to another may be attributed to certain factors that affect the profits or earnings of a firm; examples of such factors include changes in business conditions, corporate decisions, company operations, management strategies, macroeconomic conditions, and business cycles. In this article, the Esscher transform, which is a well-known tool in actuarial science, is employed to determine an equivalent martingale measure for the valuation problem in the incomplete market setting. Systems of coupled partial differential equations (PDEs) satisfied by the real-world and risk-neutral default probabilities are derived. The consequences for the swap rate of a CDS brought about by the regimeswitching effect of the firm's value are investigated via a numerical example for the case of a two-state Markov chain. We perform sensitivity analyses for the real-world default probability and the swap rate when different model parameters vary. We also investigate the accuracy and efficiency of the PDE approach by comparing the numerical results from the PDE approach to those from the Monte Carlo simulation.