Yes, you can. If you do, (iirc), the roundworm life cycle means that you'll only be infected for one lifespan, unless you're reinfected. Dogs lick their butts - that reinfects them. (I'm not googling; so this is off the top of my head) - the roundwords shed their eggs- you also end up with itching/tickling at the opposite end from your mouth. That results in many animals itching or licking - or for humans, scratching. Involuntarily scratch that nagging tickly feeling during your sleep, and it doesn't take too much more to be infected. Or, have a pet that's shedding eggs on your bed - a couple eggs on the pillow, a roll onto your face while sleeping, and you're infected.
IIRC, a lot of the heartworm medications have as the active ingredient an anthelmintic drug that fights certain types of parasites. If you're treating your dog monthly, I *think* that also covers roundworms. Though, some parasites are developing resistance to these drugs. (Occasionally switching the drug being used can help prevent this.) A lot of the common brands of heartworm preventatives contain ivermectin - and ivermectin works pretty good on a variety of intestinal parasites as well. So, if you're treating your dog monthly for heartworm, it's far less likely that you'll wind up with a ruondworm infection from your pet.