<asshat reply> Carefully.</asshat reply>
Your question is a bit too broad. My recommendation would be to start in photoshop. Compositing is little more than applying the principles of still life compositing and applying them through the advanced tools to a motion image.
The basics are: Match perspective, Match Lighting and Match Color (partly lighting).
Once you can do those 3 things, you can composite. There is a free educational copy of Fusion that is full featured. It even includes some tutorials on how to use its features. I recommned starting there. Just google for Fusion compositing and the main page should come up then download the educational copy.