This is possible a case of the fish being damaged and bacteria entering the wound. The bacteria resposible belong to the genus Aeromonas and can cause serious lesions. However, with good water quality and good feeding, the fish's immune system can often fight it off.
Watch you fish for signs of aggression, which may account for the damage, or any sharp edges within the tank. Sometimes damage is caused accidentally during the frantic rush at feeding time or during spawning behaviour.