SD cards are cheap - once they start acting up, replace them. Flash memory has a finite lifespan, so treat them as a wear item.
Even better - pick up two, and train yourself that the camera is never left without a card. Pull the one out that you just shot, replace with another one. Helps...