The phoneme can be defined as "the smallest contrastive linguistic unit which may bring about a change of meaning" (Gimson, A.C. (2008), Cruttenden, A., ed., The Pronunciation of English (7 ed.)). This definition can be clarified by a practice called minimal pair which is listing pairs of words which are different in meaning and phonologically distinct only in one phonological element.
Minimal pair can be illustrated in the following examples:
The words "pin" /pɪn/ and "pan" /pæn/ are different only in their middle sounds i.e. /ɪ/ & /æ/. Therefore the sounds /ɪ/ & /æ/ are considered to be different phonemes.
The words "pill" /pɪl/ and "bill" /bɪl/ are different only in their initial sounds i.e. /p/ & /b/. Therefore the sounds /p/ & /b/ are considered to be different phonemes.
An allophone, on the other hand, is one of a set of multiple possible spoken sounds (or phones) used to pronounce a single phoneme. It can be considered to be variations of a phoneme and doesn't change the meaning of a word.
e.g. the phoneme /p/ in the word "pill" /pɪl/ can be aspirated [pʰɪl ]. So the aspirated [pʰ] is considered to be the allophone of the phoneme /p/