"You should smile when you get your picture taken" would probably be better. This way people know for sure that you are talking about the person in the picture and not the one taking the picture.
Your sentence isn't wrong though...just unclear as to who you are talking to.
So you can say things like, "When taking a picture, try to get everyone to smile"
"You should keep a bag handy when walking your dog."
but it is more common to say it like, "When you take a picture, try to get everyone to smile."
"You should keep a bag handy when you walk your dog"
Hope this helps