It's okay to ask applicants if they have another job, but consider this:
The most effective interview questions are those that pertain directly to the open position. For instance, asking a candidate if they can legally drive doesn't make sense if you're interviewing a potential sous chef.
An applicant's employment status may or may not be related to their ability to fill your position. Rather than inquiring into potentially irrelevant, personal information, tailor your questions to fit the requirements of the job. This helps you select a candidate who has the skills and experience required for the position.
Consider what specific information you seek to gain when drafting interview questions. For instance, if you're concerned with applicants' availability, it's better to ask one of the following questions:
Questions like these can be particularly helpful if you're looking to hire independent contractors. Since they aren't employees, and can work elsewhere, asking about their schedule can help you determine if the individual fits your project's needs and timeline.
For inquiries into applicants' prior or current work experience, it's often more effective to review their resume.
Generally, Equal Employment Opportunity (EEO) laws which prevent you from inquiring about protected characteristics, such as gender, age over 40, religion, or raceare the primary limiting factors to what you can or can't ask during an interview.
Keeping your interview questions consistent for all candidates can help ensure that your questions are EEO compliant, and will help you compare candidates on equal footing. Being prepared for interviews, with a list of job-specific questions to ask every applicant effectively protects you from acting in a way that could be construed as discriminatory.
When asking if a candidate has another job, you may want to ask if the candidate has a job with one of your competitors. Some companies require employees to sign a non-compete agreement, and if they have, it might preclude them from working with you. Check out this helpful answer for more information on hiring an employee of a direct competitor.