All perfect praise be to Allah the Lord of the Worlds. May His peace and blessings be upon Prophet Mohammad and upon all his family and companions.
It is the duty of the one performing Hajj to be keen on eschewing sins more than any other person. Allah the Almighty Says {What means}: "For Hajj are the months well known. If anyone undertakes that duty therein, Let there be no obscenity, nor wickedness, nor wrangling in the Hajj. And whatever good ye do, (be sure) God knoweth it. And take a provision (With you) for the journey, but the best of provisions is right conduct. So fear Me, o ye that are wise." {Al-Baqarah, 197}.
However, if a pilgrim committed sin in state of Ihram (Ritual consecration), his Hajj isn`t invalidated unless he has sexual intercourse with his wife or another woman (Adultery). This is because the sexual intercourse itself is forbidden for the muhrim (One who is in state of Ihram). It invalidates his Hajj, according to scholarly consensus, and he must slaughter a camel.
As for the sins committed after completing the rites of Hajj, they don`t invalidate one`s Hajj. However, such a person must make sincere repentance and ask Allah for forgiveness. And Allah The Almighty Knows Best.