I am travelling from US to India, with an Indian passport but expired F1 visa and going there to get my H1B visa stamping. I have a stop at Frankfurt, Germany for 4 hours while flying to India. Do I need a transit visa for my trip?
Indian citizens do need a transit visa in Frankfurt unless exempted under some other rule, which includes having a valid US visa (which is apparently not your case) or
If they return from the USA after having used the visa (however, the return has to occur within latest four days after expiration of the validity of the visa)
That's a bit odd given the way US visas work but it's apparently the way it's interpreted in Germany. So depending on the expiration date of your F1 visa, you could be exempted under this rule. Otherwise, you will need an airport transit visa.
EDIT: The clause has now disappeared from the website (see archive.org). In the Schengen visa code, the exemption is for
third-country nationals holding a valid visa for a Member State or for a State party to the Agreement on the European Economic Area of 2 May 1992, Canada, Japan or the United States of America, or when they return from those countries after having used the visa.
That rule most definitely hasn't changed but the German interpretation might have. I am not sure how it works in practice.