Achieving a nice mix is one of the most crucial steps in music production. An amazing artist or band can record a perfect session but with poor mixing, the record can be spoiled. Music and recording is an art as much as it's a science. A lot of people ask if it's okay to mix with headphones and it's very common to hear different answers amongst different engineers. The most important thing to realize when finalizing a mix is to use many resources to reference the mix. At the very least, a mix should be listened to through many different output sources to ensure consistency across speaker types. Using headphones at some stage of the mixing process is actually highly recommended. Do you want to mix an entire song or album entirely on headphones? Definitely not! Find a pair of accurate sounding studio monitors as your standard source and reference the mix on headphones, iPhone ear buds, car stereos, cheap bluetooth speakers etc. The more sources the better.
A big reason to avoid a headphone only mix is how close and intimate the production will sound to your ears in the mixing process. Studio monitors have a natural result as it's processed by the brain. This will almost always represent a realistic final product.
Again, always check your mixes across multiple speaker systems, including headphones.