Incontinence is a common problem in dogs with many different causes, and as a result, the treatment can vary on a case-by-case basis.
Here is a list of some common causes to consider for either urinary or fecal incontinence in dogs:
Bladder infection (urinary)
Infections can cause urinary incontinence because the irritation makes dogs want to urinate often and in small amounts. This is called pollakiuria. The first test performed is typically a urinalysis and ideally a culture and sensitivity in order to identify the bacteria and antibiotic that would eliminate it.
Urinary sphincter atony (urinary)
This is caused by a lack of estrogen and this is commonly seen in female dogs after spaying. The urinary sphincter becomes loose because of the lack of estrogen which acts to prime the tone of the sphincter. A classic example of this is a dog getting up from its bed after sleeping only to reveal a small urine stain that is present there as it tends to leak out during sleep. This can be treated with estrogen supplementation or a drug that acts to increase the tone of the sphincter through neurological action.
Urinary sphincter impairment (urinary)
This could be due to a traumatic injury affecting the sphincter or nerve that controls it (such as being hit by a car), spinal injury that impairs neurological control of the nerve, neurological decline, mass lesions in the bladder physically damaging the sphincter to name a few. The diagnosis of these is based on ruling out other causes, lack of response to treatment, radiographs, contrast radiographs, ultrasound and neurological examination.
Cognitive dysfunction/senility (fecal and urinary)
In older age dogs, they can experience senility and lack the ability to discern where it is appropriate to eliminate. There are vitamins and diets that are meant to help reduce the decline they experience.
Anxiety (fecal and urinary)
Dogs that are under a level of stress can start to eliminate inappropriately. Assessing this requires ruling out other causes with tests and a thorough history to understand the likelihood of it. Multiple anti-anxiety treatments are available and they span from behavior modification, environmental management, natural supplements and medication.
These are the most common reasons for incontinence, however, others exist but they are less common. I recommend that you work with your veterinarian to identify what cause may be present in your dog.