It is not true the wrist needs to be locked during groundstrokes. Active usage of the wrist is probably the greatest technical advancement in the game in the last 30 years. You can convince yourself of this by examining the technique of all great players in the past 20 years. Here's an extraordinarily instructive and beautiful super slo-mo video of Federer's forehand, which is arguably the greatest shot of all time.
It is true that wrist-flicks are dangerous without good technique, and that the latter should precede the former, but I must emphasize the great significance of wrist usage.
Depending on your budget, you can either take lessons, or study videos of professionals' techniques and try to apply what you learn on court. If you are a beginner, the most important thing is to acquire is good form. Try to always hit with slightly bent knees and a stable upper body, slightly leaning forward.
The way to unlearn "bad" wrist-flicking is not to compromise your form. Usually, beginners try to compensate for poor stance by forcing the racquet with wrist. Avoid this, and use your wrist only to naturally enhance your strokes.