This phenomenon is called "syneresis" and can depend on incorrect cooking (too long or too short) or a too-high percentage of fat.
By replacing 10% of the sugar in the recipe with glucose syrup, you will limit the problem...