The Bible tells us to avoid even the appearance of sexual immorality (Ephesians 5:3). I do not see how masturbating can pass that particular test. Sometimes a good test for whether something is a sin or not is whether you would be proud to tell others what you had just done. If it is something you would be embarrassed or ashamed about if others found out, it is very likely that it is a sin. Another good test is to determine whether we can honestly, in good conscience, ask God to bless and use the particular activity for His own good purposes. I do not think masturbation qualifies as something we can be "proud" of or can genuinely thank God for.
The Bible teaches us, "Whether therefore ye eat, or drink, or whatsoever ye do, do all to the glory of God" (1 Corinthians 10:31). If there is room for doubt as to whether it pleases God, then it is best to give it up. There is definitely room for doubt in regards to masturbation. "For whatsoever is not of faith is sin" (Romans 14:23).