No, your elbow should absolutely not be locked when you make contact with the ball. Your arm should be nearly straight but with a slight bend at the point of contact, never completely locked. This will allow for your arm to move fluidly through the stroke and will enable you to brush up on the ball, creating topspin. You can see in this video that Federer's arm is almost straight, but his elbow is not locked when he makes contact with the ball, which allows his arm to turn over after contact (this motion makes the racquet move up as well as through the ball, creating topspin).
The pain you are feeling is most likely tennis elbow, which is a strain in the tendons in your elbow from overuse. In other words, your body simply isn't used to hitting balls that are coming at you with such high speeds, causing strain. Locking your elbow, however, brings your joint against your bones, so when you hit the ball, instead of relying on your muscles and tendons for structural support, the impact is going straight to your bones and elbow joint. Repeated impacts will wear down the cartilage in your elbow joint. Instead, keep a slight bend in your elbow at contact and strengthen your muscles. As far as the pain goes, there are plenty of braces out there to help with tennis elbow, but the Band It is the one that has given me the best results. Other than that, rest and ice your elbow and it should start to feel better.
Source: I've been playing tennis since I could barely walk, and playing competitively since middle school. I used to teach classes with students ages 5-16 at a private club.