DC is a wonderful city and often a connection point for other locations. If you have a long layover, it is worth the opportunity to see a little bit of the city.
Regan National Airport (DCA) is the closest airport to downtown DC. You can also get there from Dulles International or even Baltimore but you will need several more hours to account for transportation from the airport. From Regan National you can get from the airport to the DC mall in less than ½ hour on public transportation and 15 minutes in a taxi. From Dulles or Baltimore, you can make the trip in 30-40 minutes in a taxi or 60-90 minutes on public transportation. Both Dulles and Baltimore have a bus that links to the metro. Dulles also has the 5A bus that goes direct to Rosyln or L’Enfant Plaza in DC. The times below assume you are flying into Regan National.
3 hour layover: If you have never been to DC and you have at least 3 hours, I think it worth leaving the airport. There is a metro stop at the airport. Take the yellow line to L’Enfant and exit to 7th and Maryland. A five-minute walk north on 7th street will take you to the middle of the National Mall. From there you can do a 360 turn and see the US Capital, the national mall and the Washington Monument. Walk around a bit. If that is all the time you have, get back on the metro and head back to the airport!

4-5 hour layover:
Option 1: Now that you are on the mall, you can pop into a museum and walk around. If the stop was planned, I would do a timed entry to the National Archives. Not only will you see some of the country’s most important foundational documents but because you have a reservation you can better plan your time in order to get back to the airport. The new African American Museum also has timed entry and reservations can (and should) be made 30 days out.
If you are playing it by ear you might have to look at the lines to see which of the other popular museums are the least busy. The Air & Space museum (this is the closest museum to where you are on the National Mall), the American History museum and the Natural History museum are all worth a visit. If you are in DC during peak season and the crowds are too big at these museums, it is usually easier to see the National Museum of the American Indian or the National Gallery of Art.

Visiting the Museum | National Archives Museum
Option 2: It is 2 miles from the US Capitol to the Lincoln Memorial with the Washington Monument half way in between. Stretch your legs and walk the mall. If you only want to walk half of it, head west towards the Lincoln Memorial. On your way you can see the White House, the World War Two memorial, the Korean Memorial and the Vietnam memorial. If you have extra time you can return by way of the Roosevelt Memorial, Martin Luther King memorial and the Jefferson memorial. At any point, if you run out of time or get tired, you can flag down a taxi or call an Uber. It will be less than $20 back to the airport.

If you are hungry, plan to grab something to eat when you pass the food trucks on 14th street.
5-7 hour layover: Do both option 1 and option 2 above.