Dogs, like people, can be allergic to anything. I'm allergic to Ivory Soap.
If you believe it's either of those products, try switching to different flea & heartworm preventatives, like Advantage or Advantix for fleas or fleas/ticks, and Interceptor for heartworm.
Have you contacted your vet about your concerns?