As far as I remember there was an ancient philosopher who said something like "there is no difference (between two objects) if no difference can be detected", but I don't remember who was that and how exactly it was worded.
Could someone help me?
This sounds like the identity of indiscernibles, (not to be confused with the indiscernibility of identicals) first formulated by Leibniz. If two objects have all their properties in common, then those two objects must in fact be identical. Slightly more formally, for every x and every y: if, for every property P, x is P if and only if y is P, then x = y.
Or, equivalently, if two objects are distinct, then there must be at least one property that one object has that the other does not.
tl;dr– This is a pretty basic observation that appears in a lot of ancient works. I'd guess that you might be thinking of Heraclitus, who was big into how "no man may step into the same river twice" – because neither the man nor the river could change.
This is an ancient concept, almost certainly predating recorded history, so it's hard to guess who may've said something like this first. Among recorded statements, there're variations in translation and veracity, so it's hard to definitely analyze them all or be sure about their authenticity.
Still, the big thing that comes to mind is the "ship of Theseus" thought experiment. Basically, if there's a ship that continually gets altered, damaged, remade, etc., then in what ways can we say that it's the same thing vs. a different thing?
Heraclitus would say that things can (be recognized as) exist(ing) due to having an opposite (i.e., distinguishable alternative). Things that don't have an opposite (i.e., distinguishable alternative) don't exist (as recognizably distinct things).
This was Heraclitus's "Unity of Opposites". It seems like a lot of related quotes (which vary in part due to differences in translations) are from him.
Plato echoed Heraclitus in Plato's "Symposium", 207d [emphasis added]:
[207d] the mortal nature ever seeks, as best it can, to be immortal. In one way only can it succeed, and that is by generation; since so it can always leave behind it a new creature in place of the old. It is only for a while that each live thing can be described as alive and the same, as a man is said to be the same person from childhood until he is advanced in years: yet though he is called the same he does not at any time possess the same properties; he is continually becoming a new person, and there are things also which he loses,
This is the "no man can step into the same river twice"-thing, where the fundamental point is that, unless all properties are identical, the things are distinguishable and therefore different.
Discussion: The problem with incomplete observations.
It's easy to talk about abstract objects with fully defined properties.
The ship-of-Theseus (and more recently, the teleporter problem with p-zombies) can be more complicated because we're talking about real-world entities which don't have nice, tautological qualities defining them.
So the general conclusion is that things are recognizably different things if we can recognize a distinction between them, while things that appear to be without distinction can be "the same thing" within the limited context of that apparent lack-of-distinction.
The philosophical question folks often struggle with is if things that appear to be the same in every discernible respect can be assumed to actually be the same in all respects. Of course this is impossible to establish, which appears to have been a central theme behind Heraclitus's work.
The closest quote I can think of from ancient authors is Seneca's:"One thing must be separate from another if they are to be two" (Ep CXIII 4-5). But he allows merely numerical, not necessarily qualitative (intrinsic) difference, so this is closer to a tautology.
With the qualitative difference in mind, the principle is non-trivial, as it states that two numerically different things must also be different in some quality. It can be traced at least as far back as ancient Stoics, and the issue was discussed even before them in connection with the doctrine of eternal recurrence. Socrates, and later Plotinus, restricted its scope to a single cosmic cycle, see The Cambridge Companion to the Stoics, p.142. The medieval doctrine of Duns Scotus, who dubbed the individuating "property" haecceity (thisness), was a way to resolve the issue of qualitative copies, while keeping the principle.
Modern formulation in terms of properties is due to Leibniz, who followed Stoics, see Forman, Leibniz and the Stoics: Fate, Freedom, and Providence:
"This is the principle of the identity of indiscernibles or “Leibniz’s Law”: “For it certainly must be possible to explain why [two things] are different, and that explanation must derive from some difference they contain.” A parallel principle can be found in the Stoic view that all distinct individuals are “peculiarly qualified” (idios poion) as such. For both Leibniz and the Stoics, there would be something irrational about a world in which there would be no way to explain what makes two things different in terms of their own natures."
For a modern discussion of Stoic identity theory see Lewis, Stoics on Identity and Individuation.