It's this episode of Outer Limits: The Human Operators. I loved this episode, and the show for that matter. I can't recall seeing this same story in a scifi movie. The first three paragraphs of the plot from the linked Wikipedia article seem to describe most of what you remember:
Humanity constructs advanced military spacecraft, but the ships learn to think for themselves. They kill their crews by disengaging the life support systems. However, they keep a small number of humans alive for repairs they cannot do themselves.
One such ship, Starfighter 31, carries a father and his son, but once the father discovers that he is nothing more than a slave, he attempts to cripple the ship's computer core and is killed in the process of successfully destroying one of several spheres that apparently are critical to the core systems; in that way the ship cannot deactivate its automated defenses. This is witnessed by his son through the hatch doors.
Once the son reaches adulthood and is able to fix the core systems (so that ship can deactivate its defenses), Starship 31 rendezvous with Starship 88, whose single young female crew member is brought aboard in order to mate with him and conceive a child. The male is shown what to do by the ship through "tutorials" and with guidance from the female. He falls in love with her, and due to her effect on him, he finds himself angering the ship on numerous occasions. At different points, they are both "racked"; they are subjected to energy bolt torture, despite the risk of her having a miscarriage. When she becomes pregnant with a girl, she is told to return to her own ship. He is threatened with death in the rack if he attempts to keep her aboard.