ANSWER: The situation you are referring to in the Bible is when the disciples tried casting out a demon from a man's son but could not. The man told Jesus what happened.
'Sir (Jesus), have mercy on my son! He is an epileptic and has such terrible attacks that he often falls in the fire or into water. 16 I brought him to your disciples, but they could not heal him.' (Matthew 17:15 - 16)
Jesus, of course, could and did cast the demon out of the man's son. The son was immediately healed. Perplexed as to why they could not help the man, they asked Christ why they could not cast the evil spirit out. His response was "It was because you do not have enough faith" (Matthew 17:20). He also added, however, that it required fasting and prayer to remove the type of evil presence they had just encountered.
I have been a Christian for thirty-seven plus years and have never seen a person that I knew, without a doubt, had a demon. I have heard a minister or two that mentioned without much commenting, that they have had to deal with a demon - if they were telling the truth or not.
Years ago I witnessed an unexpected "tongues outbreak" by a fellow employee who was a member of one of the tongues-speaking Churches - he was loudly calling on Jesus and speaking words nobody knew. Everyone in the work area was startled! After my break I had to walk past the tongues-speaking employee to get to my work area. As I came near him the hair on the back of my neck stood up and I started to get goose bumps! Because I was becoming very uneasy I quickly went by the fellow worker. Did he have an evil spirit (demon) or had he worked his mind into a state of confusion? I wasn't sure what was the REAL cause of the tongues speaking but I do know, based on the person's religious beliefs, that even if he HAD a demon it was doubtful he would want it cast out!
Interestingly, just BEFORE Matthew's account of the disciples' inability to cast out a demon, Jesus had sent them on a "gospel training mission" to some cities. Before they left Jesus gave them the authority to heal the sick, raise the dead and cast out demons wherever they went (Matthew 10:5 - 15).
Another interesting thing to note is that initially the demon in Matthew 17 could not be cast out not only due to a lack of faith on the part of the disciples but also the FAITHLESSNESS of those around the demonically-possessed person, as Jesus said 'O FAITHLESS and perverse generation . . .' (Matthew 17:17). It was only after the disciples failed and the crowd was chided for their faithlessness that Jesus rebuked the demon.
These scriptures warn us that just because someone (including ourselves) believe in Jesus or uses Jesus' name does not mean they (or we) have the faith and authority from God to cast out evil spirits. Casting out demons is serious business and not to be taken lightly. Anyone taking on themselves the driving out of these spirits had better be well grounded in the scriptures and have an ample portion of God's Holy Spirit! Those who wrongly ASSUME they have the power and authority to cast out demons can suffer some very real painful consequences, as seven sons mentioned in the New Testament found out. They tried to claim power over a demon by saying 'I command you in the name of Jesus, whom Paul preaches.' (Acts 19:13). The spirit was not amused. It caused the man it possessed to attack the men and wound them (verse 16)!
Those who were claiming the ability to cast our demons were sons of a Levite chief priest. Because of this, they must have thought of themselves as being pretty important and powerful, certainly powerful enough to simply assume they could use the name (authority) of Jesus Christ (after only hearing of Him through the apostle Paul) to command obedience from fallen angels.
There was, however, one problem. These men believed all they needed to do was use Jesus' name, kind of like a magician who says some "magic words" before a trick like ABRACADABRA, and then, PRESTO, what they wanted to happen would occur! The problem was the demon(s) they were trying to cast out of a person KNEW the true power it took to FORCE them to leave and KNEW these men were ultimately only PRETENDING that they had it! Ironically, the men trying to act like they were God were in reality DECEIVED, while those whose existence was based entirely on DECEPTION (demons) knew what was the REAL truth!
Those who saw or heard of what happened quickly learned not to take the name and authority of Jesus Christ lightly --- and especially not to ASSUME they had God's authority to do whatever they pleased. If God has not ordained you to use His name for casting out demons, do not think you can simply conjure up some faith and do it anyway. Based on the Bible, it will not work!