If you have a valid US visa in your passport (so either the F1 or H1B could be OK), you can transit in Frankfurt as long as you can stay airside (in particular: the layover must be under 12 hours and your luggage must be checked through, at least to the next non-Schengen destination). See also Do I need a visa to transit (or layover) in the Schengen area? for a full explanation of the relevant rules.
Importantly, if the visa is still valid, your point of origin and your destination do not matter. There is nothing that says your H1B visa can only be used to transit on the way to the US. It would also exempt you from a Schengen airport transit visa on the way back to the US or, say, for a flight from India to somewhere in Africa.
I don't have any first-hand experience with this situation but I don't think the niceties of your status in the US (“OPT cap gap”, I-20, etc.) matter at all, as far as the German authorities are concerned.
If you are in doubt, you could ask your airline as they will be the one to check your visa status first, even before boarding the plane in the US.