Can you flip off an off duty police officer?

Yes, it's legal. In all cases in the United States at least. Even if the police officer is on duty.

Even if a city or state has some sort of disorderly conduct law, an obscene gesture law, or a profanity law, the Supreme Court of the United States has routinely and consistently weighed in on the issue and in each instance has found that it is absolutely a right of free speech to flip off a police officer, even when they're on duty. If they're off duty, this doesn't change. The rights a police officer has are the same as everyone else's, and that status does not change based on whether they are working or not.

Time magazine ran an article on this topic in 2009. If you google the name "David Hackbart" you'll find a recounting of his case, which was focused on this very issue.

Additional instances have appeared in the Supreme Court's history, as discussed in an article that you can google from the Huffington Post in 2013, which involved a man named John Swartz.

In both cases the charges were dismissed, and the people who had been cited later had their cases settled out of court by the police departments in question, with personal damages awarded for having their rights to free speech improperly infringed upon.

Yes, it's legal to flip off a cop. In all cases.

The police officer may not realize that at the time, and the first judge that hears the case might not realize that at the time he hears your case, but that doesn't make it any more illegal. The Supreme Court has ruled consistently and repeatedly that this is free speech and as such, is absolutely legal.