Could have been cured incompletely. Dental composites are cured with UV light. The composite will not cure with time, by design it will only cure with UV light. There are differences between curing tools, in penetration, in the collimated beam of light, and curing time:
https://www.dentalaegis.com/id/2012/03/principles-of-light-curing
The dental composite could have been cured incompletely, causing pain. Consider for example, a pocket of liquid composite encased beneath the cured crystalline composite, the composite in this liquid phase may experience thermal expansion and contraction, causing pressure related stress and thus pain in your tooth.
There are significant difference between practitioner skill. In my experience with one dentist, all were perfect, no pain, no failures even 10+ years later. With another, all painful, 2 fell out, not smooth... and he carved out way more enamel than necessary in their placement in my opinion. He said that was so it'd stay... what a farce...
Go back to your dentist, and have him cure the filling for two more cycles of the tool at two separate angles. You've already paid for the filling, and it was his error that led to the non-completion of the filling cure, so this will be of no cost to you. If he refuses to do this as included in the original payment, then take this issue up with your insurance company and they may recover payment for the entire service as you don't have the finished product.