In general, laptop batteries start to become problematic after 1 to 2 years or 300 to 400 charge cycles. If your laptop is old, it's likely that the battery has already expired and needs to be replaced. Generally, a new, well-made laptop battery will last for 2 to 4 years, which is equivalent to around 1000 charge cycles. Once this period has passed, it is best to get a new one.
To sum up, you should replace your laptop battery whenever necessary. Additionally, two other numbers to take into account are the full load capacity and the designed capacity. The bigger the gap between these two numbers, the more worn out the battery will be. If the full charge capacity is less than 80% of the designed capacity, it is likely that the battery has been used for too long and needs to be replaced.
In most cases, you'll notice that something is wrong with the battery because it won't last as long between charges as it used to. If overheating the battery is not part of any recall program, it's best to buy a replacement one before it can cause serious damage to other hardware components of the laptop or even cause physical injury or a fire. Both Windows and Mac OS have a feature that notifies you when your laptop's battery needs to be replaced. The first sign that something could be wrong with your laptop battery is that it doesn't last as long as before. When this happens, remove the battery and turn on the laptop with only the charger plugged in; if it turns on, the charger works fine and your laptop is still ready to work. Laptop batteries can be expensive, especially if you buy an OEM (original equipment manufacturer).
Otherwise, you'll need to take your laptop to the manufacturer's service center or local repair technician to have the battery tested. Even if your device tells you that you need to change the battery, if your device is still operating normally, you don't have to replace it. So yes, you should replace it when necessary, especially if you're someone who uses a laptop while traveling. If the battery icon still shows a red X or just an X on some laptops, or if there is no battery icon at all, then the battery may already be dead.