Per U.S. Department of Agriculture guidelines, if a soft food gets moldy, you should pitch the whole thing because the mold could have penetrated further than is visible. On hard, low-moisture fruits and vegetables, it's OK to just trim off the mold, but use good judgment.