First of all DO NOT PUNISH YOUR CAT. Punishment will NOT help the situation and will often make matters worse. Few things upset me more than when I hear about people actually rubbing their cat's (or dog's) nose in the waste as if this will help the situation! The nose did not do it!!!
Seek veterinary attention as soon as possible. There are many medical reasons why cats stop using the litter box –
Diabetes, kidney disease, cystitis (painful inflammation of the bladder), bladder or kidney stones are some of the more common medical problems that can lead to a litter box aversion.
VERY IMPORTANT: If your cat is getting in and out of the litter box and is unable to pass any urine or is looking like he is distressed and wanting to urinate outside the box this is a MEDICAL EMERGENCY! A cat with a blockage of the urinary tract can rupture his bladder within 24 hours resulting in death. You may also notice a blocked cat or one with cystitis licking the genital area frequently.
A cat with cystitis will pass SMALL amounts of urine FREQUENTLY so also make note of the size and number of the urine balls on a daily basis. A 100 percent canned food diet with its high water and low carbohydrate content must be included in the treatment for any cat with cystitis, diabetes, or bladder stones. In fact, all cats should be on 100 percent canned food or a raw meat diet. Dry food is an illogical food source for a cat and causes many health problems. Dry food, with its species-inappropriate water content, is not a friend of the urinary tract system - especially the bladder.
Once you have ruled out a medical issue, you need to evaluate your cat's litter box system:
1) Are you using an UNscented clumping litter?
2) Is his box kept very clean? Less than 3-4 items at a maximum?
3) Is his litter box big enough?
4) Is it in a safe location as far as he is concerned?
5) Are there any feline housemates that may be tormenting him in the litter box - not allowing him to enter or exit?
6) Are there enough boxes? Some cats like to urinate in one and defecate in another one.
7) If you are using a hooded box, have you tried taking the hood off?
8) If you are having problems transitioning an outdoor cat to an indoor cat and he is refusing to use the litter box, or if your cat prefers using your potted plants instead of his litter box, try using potting soil instead of clumping litter. Once the cat has used the potting soil on a regular basis for a couple of weeks, you can gradually add a small amount of clumping litter to see if you can change him over. You will need to empty the box twice daily when using potting soil and scrub the box each time. Also please understand that by using this non-clumping substrate, the urine will soak into the litter box (plastic is fairly porous and easily impregnated with odors) with only a few urinations so I strongly suggest that you get a new litter box when you switch over to using the clumping litter and start with a fresh, clean box.