The answers to this questions vary. When it comes adult fleas, you could try to vacuum them and then throw the bag right away. This, however, doesn’t work well against eggs and larvae. Another solution is to shampoo and heat-dry your carpet. The shampoo is toxic, and the heat will do a good job of killing them.
Of course, you could go to alternatives such as powders or sprays. Flea carpet powders and are found in a great variety. The first ones need you to sweep a broom in order to sink into the carpet fibers. Sprays and powders work great not only with fleas but other insects as well.