There are a few ways to get from JFK to the Empire State Building. One option is to take the Long Island Rail Road (LIRR) to Penn Station, and then transfer to the subway (either the B, D, F, or M train) to 34th Street-Penn Station. The total cost of this option is $15.50.
Another option is to take the AirTrain to Jamaica Station, and then transfer to the subway (either the E, J, or Z train) to Sutphin Boulevard-Archer Avenue-JFK Airport. From there, you can take the AirTrain to Mets-Willets Point, and then transfer to the subway (either the 7 train) to 34th Street-Hudson Yards. The total cost of this option is $13.50.
Finally, you can also take a taxi or Uber directly from JFK to the Empire State Building. The cost of this option will vary depending on the time of day and the traffic conditions, but it will typically be between $70 and $100.