The creature can only attempt to end your spell if you are probing its mind
Detect thoughts says (emphasis mine):
When you cast the spell and as your action on each turn until the spell ends, you can focus your mind on any one creature that you can see within 30 feet of you.
The "search for thoughts" bit you mention is this part:
You can also use this spell to detect the presence of thinking creatures you can't see. When you cast the spell or as your action during the duration, you can search for thoughts within 30 feet of you.
The language for the opening sentence says that you can "focus your mind" when you cast the spell or as an action, and the "search for thoughts" bit also says that you can do this when you cast the spell or as an action.
Since you can do the "focus" when you first cast the spell, and you can also do the "search" when you first cast the spell, I read this as being able to only do one of these things. It says "you can also", implying that it is an additional thing you "can" do, not something you automatically do alongside the initially described effect.
Therefore, since on later turns, continuing or switching these effects takes an action in either case, it implies that to do one effects ends the other.
From this, I conclude that the if you initially focused your mind on a creature, then on a subsequent turn switched to the "search" effect, you would no longer be focusing on that creature and it therefore wouldn't be able to make an Intelligence check to end the spell (since it's no longer "linked" to that creature as it was when you were focusing on it).
This is further supported by the fact that the Intelligence check is mentioned within the context of the "focusing your mind" part of the spell, separate from the part that describes the "searching for thoughts" part (which is described afterwards):
... the target knows that you are probing into its mind, and unless you shift your attention to another creature's thoughts, the creature can use its action on its turn to make an Intelligence check contested by your Intelligence check; if it succeeds, the spell ends