it just takes practice, i used to have that problem, still do to a point.
there are a few things you can do:
1. just work on it, as time goes by it will get cleaner and better
2. for some patterns you can barre your index finger of your left hand across the strings to dampen it. my guitar teacher showed me this. it's really good for switching strings.
3. i wouldn't recommend dampening it with anything other than some fingers. then you don't learn how to avoid the other strings. just go slow. it will come in time
To improve technique and of course trying to keep all as clean as possible. I know my own limits and speed limits and so on I never play anything I'm not capable of. That wouldn't make any sense. After three years of playing I tried to play everything as fast as possible and that sounded, I would say, like shit, and I didn't realize that if I'd play bit slower things than I was capable of playing then everything would sound much better.
--Aleksi Laiho - Advice to Play By