How can I detect when a signal deviates from a flatline?
This type of problem is part of Detection Theory.  Do you have an estimate of the background noise levels?  How about the statistics of the noise?  If the noise is AWGN, things get a little easier.  You can set a detection threshold based off your noise statistics to achieve a desired probability of detection / probability of false alarm.

Be careful about using the mean of your data to set the threshold.  The "spikes" could bias your mean estimate.  If the noise is not stationary (i.e. it changes levels), using the mean could result in false detections (alarms).  One simple option is to compute a running average and create a threshold off this running average.  If the sample of interest is above the threshold, declare a detection and do not include the sample in the running average calculation.  There're a ton of variations to this simple concept depending on the situation.

If your signal is truly a flat line without noise, you could apply a highpass filter by subtract the previous sample from the current sample.  The result would be an array of zeros with non-zero sample values at the spikes. 

For a more formal treatment of detection theory, I highly recommend Steven Kay's book "Fundamentals of Statistical Signal Processing, Volume II: Detection Theory".