When I visited Madrid, I landed on Terminal 1 (Lufthansa from Munich) and from there I walked to Terminal 2 and to the tourist board office to pick up my Madrid travel card (Abono Transporte Turístico). From Terminal 2 you'll find the metro line 8 towards the city. Just take it until the end of the journey at the stop called Nuevos Ministerios and from there take another metro line to your final destination. The journey from T2 to Nuevos Ministerios takes about 15 minutes.
As Madrid-Barajas is a big hub for intercontinental and European flights, try to come in with enough time for you to check in and go thru security check because the lines are LONG. Check if you can check in online or at check-in machines at the airport to save some time (Lufthansa has machines where you can check in).
Going to the airport from the city costs 2? on a single ticket from any metro station and 2.75? on a single combined metro ticket if taking the metro from any station in MetroSur, MetroNorte, MetroEste, TFM and Metro Ligero Oeste because you need to change lines. These prices include a 1? supplement that is to be paid when you come to the airport. More info about it on Metro de Madrid (only in Spanish). This supplement is already included in their period cards and Abono Transporte Turístico (read my separate tip about it).


