As a supplement to DVK's answer, I wanted to point out that there seems to be two ways to answer your question, based on the info in this question and from this excerpt of a Jedi using the mind trick to gain passage on a flight in Darth Bane Rule of Two (so I guess this is a Legends answer, although I don't think there's any difference in how mind tricks work between Legends and Disney canon).
"Did you want to fly us down, or should
I?" he asked her. The words were easy,
but as he said them he reached out with
the Force to touch her mind. He did it
gently, being careful not to cause her any
harm as he planted the seed of a
suggestion.
Her eyes glazed over momentarily and a
look of blank confusion crossed her
face. "Uh . .. I'll fly us down, I guess.
You can take the copilot's chair."
... As he had done with Irtanna, he gave
another slight push, adding the mind-altering
power of the Force to the half-
truth.
- The duration of the mind's susceptibility to being fooled.
The Jedi mind trick works by making the subject open to suggestion or command. The duration of this effect is active as long as the Jedi is actively using their power on the subject. Presumably an experienced Jedi could keep someone in this state for quite a long time, although as DVK points out most situations only require a few moments and one or two suggestions.
- The duration for which the subject's actions are determined by the suggestion.
I think this is really what you're asking, and I believe the answer is as long as it goes unchallenged. Consider in real life, if someone you trusted told you they found water on Neptune, you'd probably believe them until someone else you trusted refuted that claim. Or if your boss told you not to forward them any calls because they were busy, you would obey that until they told you they were available again. What the JMT does is essentially make the subject trust you, and therefore obey/believe in whatever you tell them, and according to the linked question above, they will continue to believe/obey not because they're still under the influence of the force, but because it's just a thought stuck in their brains.
So when Old Ben tells the Stormtroopers "these aren't the droids you're looking for" the Stormtroopers believed him. They never raised the alarm because those weren't the droids they were looking for, so in that sense the trick never "wears off"; but if their officer had come over and said "Go arrest them, those are the droids you want" then the new information would probably override what they had been told by Ben. You could draw an analogy between the JMT and The Doctor's psychic paper in Doctor Who, where it gives (false) information to someone which they implicitly believe, and their mind fills in a reason to believe it.