Can I use a capacitor and a transistor to create a circuit which automatically turns off an LED after a period of time?
So many things wrong with that circuit, lets go back to the start.

The transistor is a valve that lets current flow through it from collector to emitter (the pointy arrow) when current is injected into the base.. as shown below.

As such, as long as you feed current into the base, current will flow through the transistor and, if the voltage on the base is high enough, it will act like a kind of switch.

When turned on, current can flow from the battery through the LED lighting it up. The LED can only withstand so much current or it will burn out. The resistor is included to limit that current to the rated amount specified by the manufacturer's specifications.







simulate this circuit &ndash; Schematic created using CircuitLab

So now you have a circuit that will turn on an LED.

Now you need to drive that circuit with something that turns it on for a while, then turns it off. Now your idea is to do something like this.







simulate this circuit

Idea being C1 takes a while to charge up through the base limited by the resistor. Indeed with the indicated values the transistor will start to turn off around eight seconds after the power is applied. 

Unfortunately a 1mF capacitor is rather physically large and expensive. The resistor choice also affects the current in the LED.

A better solution for this task is to use a different device like an N-Channel MOSFET.







simulate this circuit

A MOSFET is gated by voltage not current. This effectively decouples the timing side from the driving side. That means you can use much larger resistances, and therefor a smaller capacitor for timing without affecting the LED current.