If you're a lucky knitter, people will give you yarn. It may not always be the yarn that you want, but of course you accept it graciously and thank the giver. While privately wondering "What the heck am I going to do with this?"
What to do with unwanted gift yarn
First assess the yarn honestly. Can you bring yourself to knit with it, or is it just too horrible?
It may be a dead grandmother's stash of vintage 1940s acrylic, unearthed from the attic. It may be half a skein of something unlabeled from the thrift store. It could be a well-intentioned (but not what you would buy for yourself) gift purchased at a yarn store. Or it could be something another knitter destashed on you. (Let's be honest - we all do this.)
The question is, now what?
First assess the yarn honestly. Can you bring yourself to knit with it, or is it just too horrible? If it isn't something you would ever in a million years knit with, don't just stash it away "for some time in the future." You won't want to knit with it then, either. Even if the Zombie Apocalypse comes, and you end up under siege in your own home, and you run out of yarn, you STILL won't want to knit with it.
If this is the case, pass the stuff along. Drop it off at a thrift store, donate it to a school's Arts & Crafts program, or find another worthy recipient. I take all my unwanted yarn to the local non-profit Senior Center. They have a knitting group of seniors on fixed incomes who are always happy for more free yarn. You can also skim the Random Acts of Kindness (RAOK) board on Ravelry, where people post their "wish list" for donors to gift them.
If the situation is not that dire, then your challenge becomes deciding what to knit with it. Let's just be up front and state the obvious: if you don't like the yarn, you won't like anything knit from the yarn. Therefore, you won't be using it to knit something for yourself.
Consider knitting something with it and giving it back to the original donor. This works particularly well for cases where a non-knitter picked out yarn for you; presumably, something about the yarn was appealing to them.
And of course, there is always charity knitting. If the yarn happens to be red, and you have a scarf's worth, the Red Scarf Project is a great and worthy charity to knit for. Many local food banks are also grateful for nice, hand-knit items to be passed out in the winter months (contact them first to ask - some food banks simply aren't set up to handle this sort of thing).