Watashiwa basically covered it, but I'll toss in my 0.02:
Warheads are generally a way to trade AIP for time. Anything you can kill with a warhead, you can kill with your fleet. Sometimes, it might take several rebuilds of your fleet to destroy the entire enemy fleet, which means saving a lot of time otherwise spent rebuilding.
It is always worth it to use a warhead to a) not die or b) win. So, the most frequent times for warhead use are when defending against a CPA (since the CPA also conveniently bunches up, making itself an easier target) and when assaulting an AI Homeworld (popping a warhead to clear out the Reserves is a core strategy).
If you find yourself defending against normal waves with a warhead, it is probably a bad thing - the time you are trading your AIP for is too short to be worth it in most cases.
If you find yourself needing a warhead to attack normal AI held systems, it is probably a bad thing - if your offensive fleet is not capable of attacking a normal system, you'll be in deep trouble when you get to the AI homeworld. Similarly, if it takes so long to clear a normal AI system with your fleet-rebuild-attack cycle, you have much the same problem. However, there are times when an AI will have just the right combination of guardposts, goodies, and/or positioning to make it very difficult to attack a normal system. That's an OK time to use a warhead (if you really need to).
For a newer player, I strongly suggest to avoid using warheads at all. Using warheads can make it easy to cover mistakes in building defenses, or fleet positioning/composition, or strategic planning, that hinder your growth of those skills. Combined with the fact that the actual cost of the AIP increase really doesn't become apparent until much later in the game, it can be easy to develop bad habits.
That was a bit rambling, so to summarize: If your find yourself using warheads against anything but the AI's big punches (CPAs, exowaves, AI HW assaults) you probably have some other problem you need to look at first before relying on warheads to fix.