It is but natural that your helmet smells bad after few months of usage. However, it is not healthy to continue using it without giving it a wash even after it starts smelling. The following lines will tell you how to give it a cleaning.
If you should own the helmet where you can remove inner lining, then you can do it much easier way. Just take off the lining as well as/or cheekpads, breath guards and visor and wash the lining under soft cycle in a washing machine adding mild detergent or shampoo.
The outer portion of the helmet can be washed in the interim using mild detergent and soft cloth. Take a wet soft cloth and add some drops of the soap on to it, give light rubbing on tough stains and rinse under water. The detergent will take a fight on the dirt and the grime and once you feel that the shell has gotten a good cleaning you can wipe off the water using a soft dry cloth. Let it dry under shade, and the shell is now good and ready to go.
There are a few who recommend to dishwasher cleaning of helmet, although I am not too sure how good it works. The grime and dirt inside the helmet is extracts of face oil (hair oil) and sweat and salts which can be cleaned using just warm water (it aint good to use too hot water or too cold water) and mild soap. You can use shampoo that gives out good smell. After the pads are dried (follow shade drying even if it takes longer time) you may have to use gluing them to the helmet lining inside.
Small tip to have the helmet clean and non smelly if you aren't going to use it for sometime: Pack the inside of the helmet with newspaper snuggly. The paper will absorb sweat and smell