Hello, ayushi14!
Thanks for using Apple Support Communities! From your post, it sounds like your iPhone is getting hot when charging and using the camera. We'll do our best to help get you in the right direction!
To help isolate the possible cause, can you test to see if this persists when you use a different Apple certified cable, power adapter, and also a different power outlet?
We also recommend using the following resource to determine if this is normal behavior or not:
Keeping iPhone, iPad, and iPod touch within acceptable operating temperatures - Apple Support
Still need help? Please Contact Apple Support for next steps.
All the best.