Inside the chimney is a damper that can be open or closed. Make sure the damper is working correctly and that is open and stays open when you intend to have a fire. You should also check where the chimney penetrates the roof to validate the flashing and waterproofing is not worn out or damaged. This can often times be a source of leaks into the attic around the chimney opening.
Before starting a fire, check to make sure the damper is open. Usually there is a latch at the top of the fireplace that swings the damper open or close. Use a flashlight to look up to verify the damper is open.
Once your fire is out, let the fireplace cool before you try to swing the damper closed as the metal is probably very hot. Once cooled, you can close the damper to prevent heat from escaping the interior of your home, or prevent rain from coming into the fireplace.
Here is a great video from Essortment.