MySQL MyISAM REPAIR TABLE lost connection to MySQL server during query
First, I need to ask "Does the OPTIMIZE actually help?"  I ask because it is very rare that it makes enough difference to bother with.  Please describe the activity on the table.  One case that might need the optimize is a huge amount of deletes and/or updates (with different lengths).  If the deletes are of "old" data, then we should discuss partitioning as a much better way.

What setting do you have for myisam_recover_options?  That would let the server deal with the REPAIR automatically.

You really should consider changing to InnoDB which will mostly eliminate the need for OPTIMIZE and REPAIR.  Also MyISAM is going away.

On another topic,...  Have you identified the query/queries that are involved in the CPU spike?  It could be that we can speed them up enough to avoid the problem.  Sometimes it is as simple as adding a suitable composite index.