We discuss a general problem of optimal strategies for insurance, consumption and investment in a changing economic environment described by a continuous-time regime switching model. We consider the situation of a random investment horizon which depends on the force of mortality of an economic agent. The objective of the agent is to maximize the expected discounted utility of consumption and terminal wealth over a random future lifetime. A verification theorem for the Hamilton-Jacobi-Bellman (HJB) solution related to the optimal consumption, investment and insurance is provided. In the cases of a power utility and an exponential utility, we derive analytical solutions to the optimal strategies. Numerical results are given to illustrate the proposed model and to document the impact of switching regimes on the optimal strategies.