Is it safe to use gentamicin ophthalmic solution to cure a stye?

Yes - But. Always try hot compresses and eyelid scrubs with baby shampoo first, often works alone. Antibiotic drops or ointment may also be required but there are better choices that gentamicin alone- a combination antibiotic and steroid such as blephamide or tobradex (tobramycin and dexamethasone) for example, and only on the recommendation of your eye care doctor.
Yes, but... Yes as long as it was prescribed by your eye care professional. Do not use other people's eye drops.