This is a Community Wiki post. If you see a way to improve it, please go right ahead and edit it.
There are multiple factors that go into the answer in your particular case.
- Is there an official update from the carrier/manufacturer? Then use the official method.
- Is there no official update, but has someone created a ROM that you could install on your rooted device? Then you need to look for how to update unofficially.
- If you have a little programming knowledge, and you know about Linux device drivers, you could try to make a custom ROM for the device. Start with an existing ROM project such as Cyanogenmod and port it to your hardware. This will take a lot of effort, there's a risk of bricking your phone, and it might not even be possible for your device (because of lack of drivers). If you still think it's worth a try, ask the developers of the ROM you're starting with where to start. (Note that questions about writing custom ROMs are off-topic on this site.)
- If there is neither an official update nor a custom ROM, and you don't have the knowledge or free time to port one yourself, then your only other option is to buy a new device.
First, check to see that there is an official update for your device.
For most devices, you simply go to
Settings | About phone | System updates. If the update is ready for your particular device, it will tell you so. If you're lucky, you won't even need to go that far, as there will be a notification telling you that an update is ready.
Note that it takes time for carriers and manufacturers to add their customizations to the OS. Just because a new version has been announced doesn't mean it's immediately available for your device. Even when a particular OS update is announced for your device, it is almost always a phased rollout, meaning that it could be days or weeks from the official release for it to be available for you. (Very often the update file is made available for savvy users to update manually.)
Some device manufacturers/carriers have slightly, or grossly, different ways of distributing updates. Samsung, for instance, was notorious for requiring users to use their Kies software, although recent updates have come over-the-air.
If there is no official update for your device, you either need to wait for one (if one will be made) or install a custom ROM. There is a vibrant mod community that works very hard to make new OS updates available for old devices and devices where the manufacturer/carrier is very slow to do their customizations.
Rooting and flashing ROMs to your device is too large a topic to be covered in this post. Please refer to these other questions for that: