Joseph died when Jesus was between 12 to 33 years old
Based off scripture we can deduce that Joseph died when Jesus was between the age of 12 and 33. We know that Joseph is still alive when Jesus is 12, as he and Mary search for Jesus who is 'missing.' There is no mention of Joseph after this event in Christ's life. It is believed that he probably died before Jesus started his public mission because we find Mary mentioned and present a few times but never Joseph; except when it is remarked that Jesus is the son of Joseph the carpenter. With that in mind and a solid possibility that he died before Jesus was 30, we know for sure that Joseph was already dead when Jesus was 33 because that would have been around the age Jesus was put to dead. By Jesus' placing Mary in the care of the apostle John during his execution this would suggest no one is left to take care of Mary. This leads us to believe that Joseph is already dead.
Granny Annie brings up a good observation. She mentioned in her answer above that Joseph would have died after Jesus learned the family trade from him. That makes sense as it is assumed that Jesus worked as a carpenter until he turned 30, and started his public mission.
I should note that Jesus' entrusting Mary in the care of John is significant on many levels, not just by the obvious (that there is no one left to take care of her). In giving Mary as John's mother and John has her son, Jesus is symbolically giving Mary to all of us. He is giving Mary to be mother of his Church, and we who are the Church of Christ to be the sons of the Mother of God.