Why is my iPhone 3GS proximity detector not working?
I don't remember ever reading about a problem with proximity sensors in iPhone 3GS running iOS 4.x. The well-known problem was with iPhone 4, and it was fixed in iOS 4.2.1.

I guess you will have to restore your iPhone, either to verify that your problem was caused by some rogue app you installed via jailbreak or to take the phone to an Apple Store.