In order to felt a knitted project, you will need to knit the item using 100% wool yarn, and make sure to knit it larger than you want the final product to be. Felting will shrink a knitted project about 40%, depending on the brand of yarn.
Technique video courtesy Christy Nelson
Note: This technique will only work if you have a top-loading washing machine. High-efficiency and front-loading machines often don't use enough water to felt knitting evenly. If you don't have a top-loading washing machine, you can still felt your knitted project by hand.