Uncle Vernon locks Harry in his room as punishment because he learned that Harry wasn't allowed to do magic outside of school, which made Uncle Vernon feel much less afraid of Harry.
Harry is being punished because he was told to keep quiet in his room while the Dursleys had dinner guests so that Uncle Vernon could close a very important business deal. Things went awry when Harry enters his room to hide for a while, only to find Dobby who was imploring him not to go back to Hogwarts. This causes an argument between Dobby and Harry which draws Uncle Vernon's attention, though he recovers his dinner party. Vernon's deal is finally completely ruined when an owl arrives and delivers a piece of mail right on one of the guest's heads. This letter revealed to him that Harry is forbidden to do magic at home until he graduates.