I assume that you are referring to an excision for a growth or cyst on the scalp.
It would be best to allow the surgical wound to heal before dyeing the hair to minimise any irritation to the wound which may occur with dyeing the hair. This is to maintain optimal wound healing conditions.
If you have a history of allergy to hair dye, then this should be strictly avoided as this can trigger a skin rash and affect the wound healing.
Once your wound has healed, it should be fine to dye your hair if you do not have any allergy to the hair dye.