There is no database that provides that information for more than a handful of languages. You would need (1) an accurate list of phonetic segments systematically used in a language, for many languages (we don't have that) and (2) phonological analyses of those languages (such information is spotty, but generally in better shape than phonetic details). Traditionally, a good language description would list the phonemes and include a statement of the "allophones" of those phonemes, but usually that information is not exhaustive, it mentions only the most noteworthy variants.
You might be able to get some information on a pair-wise basis, simply by looking at the Wiki entries for the specific sound (e.g. f,φ or x,χ) which might mention a language either where the sound "contrasts" with the other sound, or it may say that the sound is an allophone of the other sound. You would still have to dig into the source materials for the language to verify the claim, but it increases your odds of getting an answer compared to just reading books and articles at random (where you might read numerous articles on Norwegian before concluding that they don't have [φ] at all). You will miss some examples (English has both f,φ the latter being an allophone of /p/) because Wiki omits that information. Apart from basic under-reporting of data, you will face interpretive problems that "phoneme" and "allophone" mean different things to different people (is [ɾ] a phoneme of English, or an allophone? Is the contrast between capitalistic and militaristic" allophonic or phonemic?).
I think it matters why you want to have such information. If the question is about attested contrasts in human languages, it is easier to find some robust example of the [f,φ] contrast (Venda or Ewe), but if you want to know how the [f,φ] constrast statistically compares with the [φ,θ] contrast, you're asking for more than we can tell you (meaningfully).