Sorry you're having problems with your knee and I hope it's nothing serious.
I notice that lots of people have read but no-one's replied yet, I think this is because the folks on here need a bit more information before they can even begin to guess at what might be wrong. You say it hurts when you straighten it, or when it's bent for long periods of time, where on your knee does it hurt? and what does the pain feel like? Is it constant pain, a sharp sudden pain as you move it, a tingling or burning sensation? does it make any noises (clunks/clicks/grating sounds)? Does it get hot or swell up? Can you walk on it? does it give way?
The Doctor will decide about surgery following examination, and possibly xrays or mri scans depending on what they think is wrong. Whether you get a cast or brace or nothing at all will also depend on what they find is wrong.
The more information you can give us the more helpful we can be!