If by changing companies, you're referring to a change in ISP (cable/dsl), it depends. If you're switching types (cable to dsl, or vice versa), you need a different modem since the technologies are different. If it's the same type (cable to cable, or dsl to dsl), it depends. You can often use the same modem, but other times the ISP insists you use their modem. Nowadays most ISP providers provide the modem free of charge, so it shouldn't be a concern anyway.
Routers are a different story. Most any router can be used w/ either cable or dsl, so you can switch ISPs and reuse the router.