where I live is having a bit of a heat wave.... 2 days being in the high 30s and today being in the 40s
I am assuming those temperatures are Celsius. (I usually think in Fahrenheit, but will use google to convert.)
I mostly know about chickens, not ducks, but here's what I can piece together from chicken knowledge plus some internet research for duck-specific details.
It usually works to provide a heat lamp in one end of the chicks' space, with the other end cooler, and let the chicks move around depending on what temperature they want. It's usually good to have their space at least a meter long, so they have some variation of temperature (maybe 40 C at the hottest point and around 20 C at the cooler end, if you can manage it. Realistically, whatver your air conditioning can provide in the cool area.)
I think that would work for ducklings too.
That idea only works with baby birds that are able to move around, so if this duckling is strong enough to walk, it would probably work. If the duckling cannot walk, it would not be such a good idea.
I'm just scared that the constant change of temp will make things worse
For baby ducks and chickens, it is normal for them to snuggle under the mother to get warm, then come out and walk around in cooler temperatures, then get cold and go snuggle under the mother again.
So I would not be too worried about changing temperature.
If the duckling cannot walk, I would probably try to use a thermometer to check temperature, and try to get an area about 38 Celsius (about 100 Fahreneheit), then put the duckling there for a bit. Given your current weather, there might be a spot outdoors in the shade that you could use.
I would probably try not to have it in direct sun, or under the hottest part of a heat lamp, to avoid overheating. So I would aim for a bit to the side of the heat lamp, or in the shade outdoors, or on a heating pad that has a thermostat so it has a consistent temperature. Or under the mother duck, if she's in the mood to sit still for a bit, but she may be too busy taking care of the other ducklings.
The internet tells me that the normal rectal temperature for an adult duck is 38 to 40 degrees Celsius (source: 1949 study "Body temperature, heart rate and respiration rate of an unrestrained domestic mallard duck, anas platyrhynchos domesticus" by authors Norbert Smith, Connie Peterson, Kenneth Thigpen)
If you have a way to safely measure the rectal temperature of the duckling, it may help you figure out whether temperature is a problem, and which direction it is wrong.
Note about temperatures:
For a duckling that cannot move around but might be cold, I suggested 38C (about 100F) because that's close to the body temperature of a duckling or chick, so it is appropriate for warming one that is already chilled. Or for a cold duckling that can walk, I would provide access to a range of temperatures both cooler and even warmer than that. This is a bit different than raising normal healthy ducklings, where it is usually recommended to have a warm area closer to 32-35C, also with access to cool areas.
If someone has duck-specific knowledge, hopefully they will chime in. But if no-one shows up, hopefully this will help.
I didn't see the thread until some hours after you posted, so this may all be too late to be useful
