Try on different earpiece sizes
In almost every package of earbuds with silicone or foam earpieces, the manufacturer includes several different-sized replacement earpieces. These sizes can range from the very small to the very large. You can very easily pull off the earpiece and replace it with the new size. Just firmly and deftly pull the earpiece off from the earbud speaker stalk, and then replace by gently easing the new piece onto the earbud. (Reference 5)
Fit them properly
Another oft-encountered problem is fitting. Wearers often simply push the earbud into place, causing discomfort, and possibly a poorer listening experience. In order to ensure a tight and comfortable fit, seat the earbud securely in your canal pulling on the outer ear or earlobe to open up your ear canal. Gently insert the earbud into a comfortable position, and let go of your ear. This should seal the ear around the earbud properly as well as provide more comfort. (Reference 1)
Even if you take all of the recommended steps, some earbuds will simply refuse to fit properly. It is important to shop around for different pairs and put them to the test. Peruse your local electronics store for pairs that look suitable for you, and try them out. Sports earbuds like the AmazonBasics Sport In-Ear Headphones ($18) (Reference 3) are made with an over-the-ear piece to fit securely to your ears. The Bose SoundTrue In-Ear Headphones ($90) (Reference 4) has small rubber nubs that help the earbuds grip the ear.
If all else fails...
If nothing you try or buy works for you, but you do not want hoist a pair of over-ear headphones, you can try to fasten the earbuds to your ears by means of a hat or hairband. (Reference 6) Although this is not the best option, and may cause discomfort and poor sound quality, it will keep the earbuds in place.
You get what you pay for. If you are really interested in quality, expect to invest more into a good pair of earbuds. To be certain of quality, research consumer reviews on different pairs.
Don't push the earbuds too far or too forcefully into your ear. The silicone rubber or foam tips can become lodged deep into your ear canal (Reference 2), and can cause extreme discomfort or possible damage.