Because hamsters do not generally go outside, they do not usually get fleas. However, they can sometimes get them from your other pets. If this happens, you will want to get rid of the fleas as quickly as possible. However, you shouldn't use any of the medications meant for other larger animals on your hamsters as this may cause an adverse reaction due to their size.
Remove the hamster from its cage and transfer it to a clean carrier.
Clean the hamster's cage thoroughly. Remove all of the old bedding and other things inside the cage. Place them in a plastic bag and tie it tightly so that any fleas inside the bag will not be able to escape. Vacuum the cage, including its surroundings. If the floor is carpeted, make sure to vacuum it as well. After vacuuming the cage, take warm water and use it to wipe the cage and other plastic items inside of the hamster's cage. Let it dry.
Prepare clean bedding for the hamster and arrange it in the cage once it has dried. Put your hamster back into its cage.
Wash your hamster using warm water and shampoo specifically made for hamsters. Do not use flea and tick shampoo for dogs or cats as this will be too strong.
Spray your hamster's cage and bedding using a flea and mite spray meant for hamsters. Do not use the off-the-shelf ones meant for cats and dogs as these may be harmful to your hamster. If you can't find one, consult your vet.