All buses leave from Terminal 5 in JFK Airport. The following lines connect the airport with Queens, Brooklyn and Manhattan: Q3, Q6, Q7, Q10, Q10 LTD and B15. Most of these buses run for 24 hours a day, but see the JFK Airport website timetable here. One-way tickets are $2.75.
The JFK AirTrain connects the airport to Jamaica and Howard Beach Stations, where passengers can transfer to subway lines that go into the city. Catch the AirTrain from the arrivals level in any terminal. From Jamaica Station, take the Long Island Railroad to get into NYC and from Howard Beach Station, catch the A Line. Tickets from the airport to Jamaica or Howard Beach cost $5.
The JFK Airport website has a list of authorized companies that offer shuttle services from the airport. Many companies offer options for different vehicles and services. These can be booked in advance or at the airport, although waiting times may be longer if booking at the airport. Go AirLink NYC, like most companies, offers a fare estimate on its website.