Matthew 5:16 "Let your light so shine before men, that they may see your good works, and glorify your Father which is in heaven. "
Matthew 6:1 "Take heed that ye do not your alms before men, to be seen of them: otherwise ye have no reward of your Father which is in heaven. "
These two scriptures are seemingly contradictory when just read as they stand by themselves. However, a proper understanding is gained by observing the context of each verse, and it will become evident quickly that there is no contradiction between them. The context is the key to a correct understanding and to solving the difficulty. Both verses are part of the same teaching of Jesus , the so called "sermon on the mount", and it would certainly be strange that Jesus would contradict himself in the same teaching.
In Matthew 5:16, Jesus is speaking in the context of being a witness, of being the salt of the earth, of proclaiming the good news of the kingdom not only by words but also by our deeds. He is speaking of those works which are done not with man or oneself in mind, but rather which serve the purpose of bringing glory to God, as it says "and glorify your Father which is in heaven."
In Matthew 6:1, Jesus is speaking in the context of "doing alms before men" quite a contrast to what he was describing in the earlier section of his teaching. These here are "good works" which some people do in a "self-righteous" sense, with the intention of drawing attention to oneself ("to be seen of them [other men]"). The alms or "good works" spoken of here are not the same works as he mentioned before rather, he is speaking of an entirely different situation and completely different intents and purposes for those deeds.
When we do good deeds toward other men in helping those in need, we are to do so without a lot of publicity campain, rather we do it humbly and quietly. Such works will be noticed, certainly by those who are being served, and most definitely by the Father in heaven who sees into secret places. Thus, as opportunity arises, we would let our light shine to the glory of God. If we would do such deeds of helping others only in connection with loud bragging or advertising to ensure people's recognition in order to appear before them in a certain way, we would fall into the second and inappropriate category mentioned by Jesus. Doing "good works" in accordance with the first directive will eventually draw people toward God and will glorify Him, doing things according to the manner which Jesus refuted, will not glorify God in the least.