You won't offend. But if the person is suicidal, he will be so glad to have someone who cares enough to ask. Asking will not put the thought in the person's mind and cause him to do something that he would not have done otherwise. Most people are. Assume the worst.
Next thing is to ascertain how serious they are.
Compare it to finding out how serious a friend is about getting married. If he isn't engaged, and doesn't even have a steady girl friend, he likely won't be getting married for quite a while. But if he tells you that he will be marrying Miss Heart-Throb in First Church at 2 PM next Sunday, take him seriously. The last three are key. In Canada, the sparsely settled North has the highest suicide rate, and Newfoundland, where family and community ties are strong, has the lowest rate per hundred thousand.