You can take a bus or train from Penn Station in Manhattan to Washington, DC and then local transportation from there to your Maryland destination. From JFK you can take the NYAS express bus to Penn Station or Airtrain from terminal to Jamaica Station and E subway or Long Island RR to Penn Station. Boltbus, Megabus and Vamoose Bus leave from the Penn Station area or you can take Amtrak train but bus is cheaper. Once in DC take the Metro Red Line subway to Shady Grove, this stop is closest to Montgomery Village.
You can take a bus or train