Most vets will want to test your dog prior to putting them on heartworm preventative if there has been a lapse, just to be certain your dog isn't HW positive prior to beginning preventative. There is a risk in giving heartworm preventatives if a dog has heartworm, so the vet wants to know what your dog's status is in order to be safe. That said, if a dog is newly infected by heartworms, it takes around 6 months to mature to the point that they will test positive. That's why they recommend testing 6 or so months after possible exposure. However, since your dog was potentially exposed months ago and could potentially be hosting adult worms, my guess is that they will recommend testing now (before starting prev), as well as maybe in 6 months, to be safe.
Keep in mind that you aren't necessarily preventing heartworm infection entirely, merely controlling the life cycle of the heartworms so that larvae are killed prior to maturing into damaging adult heartworms. So, you need to be treating for at least one month after last possible exposure, maybe longer, depending on the preventative, as well as other factors.
That said, I usually let my dogs lapse on HW preventative in the winter, test in spring, and put back on preventative
ETA: You can see the latest and greatest heartwporm prevention recommendations here: https://www.heartwormsociety.org/
and don't hesitate to call your vet and ask them what their policy is.